mirror of https://github.com/jumpserver/jumpserver
perf: history account model queryset (#8588)
Co-authored-by: feng626 <1304903146@qq.com>pull/8592/head
parent
f758414844
commit
4a3d7a8524
|
@ -30,7 +30,11 @@ class AccountHistoryViewSet(AccountViewSet):
|
||||||
http_method_names = ['get', 'options']
|
http_method_names = ['get', 'options']
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = AuthBook.get_queryset(is_history_model=True)
|
queryset = self.model.objects.all() \
|
||||||
|
.annotate(ip=F('asset__ip')) \
|
||||||
|
.annotate(hostname=F('asset__hostname')) \
|
||||||
|
.annotate(platform=F('asset__platform__name')) \
|
||||||
|
.annotate(protocols=F('asset__protocols'))
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,8 @@ class AuthBook(BaseUser, AbsConnectivity):
|
||||||
logger.debug('Update asset admin user: {} {}'.format(self.asset, self.systemuser))
|
logger.debug('Update asset admin user: {} {}'.format(self.asset, self.systemuser))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_queryset(cls, is_history_model=False):
|
def get_queryset(cls):
|
||||||
model = cls.history.model if is_history_model else cls
|
queryset = cls.objects.all() \
|
||||||
queryset = model.objects.all() \
|
|
||||||
.annotate(ip=F('asset__ip')) \
|
.annotate(ip=F('asset__ip')) \
|
||||||
.annotate(hostname=F('asset__hostname')) \
|
.annotate(hostname=F('asset__hostname')) \
|
||||||
.annotate(platform=F('asset__platform__name')) \
|
.annotate(platform=F('asset__platform__name')) \
|
||||||
|
|
Loading…
Reference in New Issue