perf: 接口sql优化 /api/v1/accounts/account-templates/su-from-account-templates/

This commit is contained in:
fangfang.dong
2023-06-27 10:45:50 +08:00
parent bccf3a0340
commit 4e9012cc07
2 changed files with 4 additions and 5 deletions

View File

@@ -124,10 +124,10 @@ class AccountTemplate(BaseAccount):
]
@classmethod
def get_su_from_account_templates(cls, instance=None):
if not instance:
def get_su_from_account_templates(cls, pk=None):
if pk is None:
return cls.objects.all()
return cls.objects.exclude(Q(id=instance.id) | Q(su_from=instance))
return cls.objects.exclude(Q(id=pk) | Q(_id=pk))
def get_su_from_account(self, asset):
su_from = self.su_from