优化查询状态

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent 58472fb9e4
commit ef243feb9f
  1. 2
      fir_ser/common/notify/ntasks.py
  2. 2
      fir_ser/xsign/utils/ctasks.py
  3. 12
      fir_ser/xsign/utils/modelutils.py
  4. 2
      fir_ser/xsign/views/admin/supersign.py
  5. 5
      fir_ser/xsign/views/supersign.py

@ -103,7 +103,7 @@ def check_apple_developer_devices(user_obj, days=None):
developer_queryset = AppIOSDeveloperInfo.objects.filter(user_id=user_obj)
if developer_queryset.count() == 0:
return
developer_used_info = get_developer_devices(developer_queryset)
developer_used_info = get_developer_devices(developer_queryset, user_obj)
device_count = developer_used_info.get('can_sign_number', 0)
if user_obj.notify_available_signs == 0 or device_count > user_obj.notify_available_signs:
return

@ -67,7 +67,7 @@ def auto_check_ios_developer_active():
for uid, developer_obj_list in error_issuer_id.items():
userinfo = UserInfo.objects.filter(uid=uid).first()
developer_used_info = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=userinfo))
developer_used_info = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=userinfo), userinfo)
end_time = datetime.datetime.now().date()
start_time = end_time - datetime.timedelta(days=1)

@ -11,8 +11,8 @@ from django.db.models import Count, Sum, Q
from api.models import AppReleaseInfo, UserInfo
from common.base.baseutils import is_valid_phone
from common.constants import SignStatus
from common.core.sysconfig import Config
from common.constants import SignStatus, AppleDeveloperStatus
from common.core.sysconfig import Config, UserConfig
from xsign.models import APPSuperSignUsedInfo, UDIDsyncDeveloper, AppUDID, APPToDeveloper, AppIOSDeveloperInfo, \
IosDeveloperPublicPoolBill, IosDeveloperBill, DeveloperDevicesID, AppleDeveloperToAppUse, DeveloperAppID, \
AppleSignMessage, DeviceAbnormalUDID
@ -126,7 +126,7 @@ def get_use_number(developer_obj):
return DeveloperDevicesID.objects.filter(developerid=developer_obj).values('udid').distinct().count()
def get_developer_devices(developer_obj_lists):
def get_developer_devices(developer_obj_lists, user_obj):
developer_obj_lists = developer_obj_lists.filter(status__in=Config.DEVELOPER_USE_STATUS).all()
result_info = []
for dev_obj in developer_obj_lists:
@ -152,12 +152,16 @@ def get_developer_devices(developer_obj_lists):
"max_total": 100 * len(result_info)
}
developer_status = Config.DEVELOPER_SIGN_STATUS
if UserConfig(user_obj).DEVELOPER_WAIT_ABNORMAL_DEVICE and UserConfig(user_obj).DEVELOPER_ABNORMAL_DEVICE_WRITE:
developer_status.append(AppleDeveloperStatus.DEVICE_ABNORMAL)
for info in result_info:
use_num['other_used_sum'] += info['other_used']
use_num['flyapp_used_sum'] += info['flyapp_used']
use_num['all_usable_number'] += info['usable_number']
use_num['all_use_number'] += info['use_number']
if info['status'] in Config.DEVELOPER_SIGN_STATUS:
if info['status'] in developer_status:
use_num['can_sign_number'] += (info['usable_number'] - info['flyapp_used'] - info['other_used'])
use_num['used_sign_number'] += info['usable_number']
use_num['can_other_used'] += info['other_used']

@ -122,7 +122,7 @@ class SuperSignBillUserInfoView(APIView):
'used_balance': get_user_public_used_sign_num(user_obj),
'all_balance': get_user_public_sign_num(user_obj)
}
use_num = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=user_obj))
use_num = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=user_obj), user_obj)
private_balance_info = {
'used_balance': use_num.get('flyapp_used_sum', 0) + use_num.get('other_used_sum', 0),
'all_balance': use_num.get('max_total', 0)

@ -68,7 +68,7 @@ class DeveloperView(APIView):
if status_choice is not None and isinstance(status_choice, list) and status_choice:
developer_obj = developer_obj.filter(status__in=status_choice)
developer_obj = developer_obj.distinct()
res.use_num = get_developer_devices(developer_obj)
res.use_num = get_developer_devices(developer_obj, request.user)
if issuer_id:
developer_obj = developer_obj.filter(
Q(developerappid__app_id__bundle_id=issuer_id, developerappid__app_id__user_id=request.user) | Q(
@ -675,7 +675,8 @@ class DeviceTransferBillView(APIView):
user_obj = request.user
if user_obj.pk != to_user_obj.pk:
try:
use_num = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=user_obj))
use_num = get_developer_devices(AppIOSDeveloperInfo.objects.filter(user_id=user_obj),
user_obj)
all_balance = use_num.get('max_total', 0)
if all_balance > 0 and number <= all_balance:
bill_obj = IosDeveloperBill.objects.filter(user_id=user_obj, to_user_id=to_user_obj,

Loading…
Cancel
Save