Merge pull request #10826 from jumpserver/pr@dev@perf_account_template

perf: 接口sql优化 /api/v1/accounts/account-templates/su-from-account-templates/
This commit is contained in:
老广
2023-07-04 13:42:04 +08:00
committed by GitHub
2 changed files with 4 additions and 5 deletions

View File

@@ -137,10 +137,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