From b270d8e5c6489d76cf4a04cc69ab11da0ba374ba Mon Sep 17 00:00:00 2001 From: MMXX Date: Tue, 11 Jan 2022 17:32:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=9F=E5=90=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/modelutils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fir_ser/api/utils/modelutils.py b/fir_ser/api/utils/modelutils.py index 7f37e73..5e9fa1f 100644 --- a/fir_ser/api/utils/modelutils.py +++ b/fir_ser/api/utils/modelutils.py @@ -87,8 +87,10 @@ def get_app_download_uri(request, user_obj, app_obj=None, preview=True): def get_min_default_domain_cname_obj(is_system=True): - return min(DomainCnameInfo.objects.annotate(Count('userinfo')).filter(is_enable=True, is_system=is_system), - key=lambda x: x.userinfo__count) + domain_queryset = DomainCnameInfo.objects.annotate(Count('userinfo')).filter(is_enable=True, is_system=is_system) + if not domain_queryset: + return DomainCnameInfo.objects.filter(is_enable=True, is_system=True).first() + return min(domain_queryset, key=lambda x: x.userinfo__count) def get_filename_form_file(filename):