From d418647774ee70a50afe66ad893dcd732aa87cb2 Mon Sep 17 00:00:00 2001 From: Bai Date: Mon, 22 Apr 2024 19:36:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E4=BC=9A=E8=AF=9D=E6=8E=92=E5=BA=8F=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E9=83=BD=E6=98=AF=201=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/jumpserver/api.py b/apps/jumpserver/api.py index 2de0b7b07..6b5d162e5 100644 --- a/apps/jumpserver/api.py +++ b/apps/jumpserver/api.py @@ -186,13 +186,15 @@ class DatesLoginMetricMixin: return self.get_date_metrics(Session.objects, 'date_start', 'id') def get_dates_login_times_assets(self): - assets = self.sessions_queryset.values("asset").annotate(total=Count("asset")) \ + assets = self.sessions_queryset.values("asset") \ + .annotate(total=Count("asset")) \ .annotate(last=Cast(Max("date_start"), output_field=CharField())) \ .order_by("-total") return list(assets[:10]) def get_dates_login_times_users(self): - users = self.sessions_queryset.values("user_id").annotate(total=Count("user_id")) \ + users = self.sessions_queryset.values("user_id") \ + .annotate(total=Count("user_id")) \ .annotate(user=Max('user')) \ .annotate(last=Cast(Max("date_start"), output_field=CharField())) \ .order_by("-total")