mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 08:55:40 +00:00
perf: Report localtime
This commit is contained in:
@@ -62,7 +62,8 @@ class ChangeSecretDashboardApi(APIView):
|
|||||||
status_counts = defaultdict(lambda: defaultdict(int))
|
status_counts = defaultdict(lambda: defaultdict(int))
|
||||||
|
|
||||||
for date_finished, status in results:
|
for date_finished, status in results:
|
||||||
date_str = str(date_finished.date())
|
dt_local = timezone.localtime(date_finished)
|
||||||
|
date_str = str(dt_local.date())
|
||||||
if status == ChangeSecretRecordStatusChoice.failed:
|
if status == ChangeSecretRecordStatusChoice.failed:
|
||||||
status_counts[date_str]['failed'] += 1
|
status_counts[date_str]['failed'] += 1
|
||||||
elif status == ChangeSecretRecordStatusChoice.success:
|
elif status == ChangeSecretRecordStatusChoice.success:
|
||||||
|
@@ -5,6 +5,7 @@ from collections import defaultdict
|
|||||||
from django.db.models import Count, Q, F, Value
|
from django.db.models import Count, Q, F, Value
|
||||||
from django.db.models.functions import Concat
|
from django.db.models.functions import Concat
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
from django.utils import timezone
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
from accounts.const import Source
|
from accounts.const import Source
|
||||||
@@ -39,7 +40,8 @@ class AccountStatisticApi(DateRangeMixin, APIView):
|
|||||||
|
|
||||||
data = defaultdict(set)
|
data = defaultdict(set)
|
||||||
for t, _id in filtered_queryset.values_list('date_change_secret', 'id'):
|
for t, _id in filtered_queryset.values_list('date_change_secret', 'id'):
|
||||||
date_str = str(t.date())
|
dt_local = timezone.localtime(t)
|
||||||
|
date_str = str(dt_local.date())
|
||||||
data[date_str].add(_id)
|
data[date_str].add(_id)
|
||||||
|
|
||||||
metrics = [len(data.get(str(d), set())) for d in self.date_range_list]
|
metrics = [len(data.get(str(d), set())) for d in self.date_range_list]
|
||||||
|
Reference in New Issue
Block a user