mirror of https://github.com/jumpserver/jumpserver
perf: change password dashboard
parent
dab97ea16c
commit
81b1deebbe
|
@ -38,7 +38,8 @@ class UserChangeSecretApi(DateRangeMixin, APIView):
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.debug(f"Failed to get city for IP {ip}, skipping", exc_info=True)
|
logger.debug(f"Failed to get city for IP {ip}, skipping", exc_info=True)
|
||||||
continue
|
continue
|
||||||
return dict(data)
|
|
||||||
|
return [{'name': k, 'value': v} for k, v in data.items()]
|
||||||
|
|
||||||
def get_change_password_metrics(self, queryset):
|
def get_change_password_metrics(self, queryset):
|
||||||
filtered_queryset = self.filter_by_date_range(queryset, 'datetime')
|
filtered_queryset = self.filter_by_date_range(queryset, 'datetime')
|
||||||
|
@ -64,14 +65,17 @@ class UserChangeSecretApi(DateRangeMixin, APIView):
|
||||||
|
|
||||||
total = qs.count()
|
total = qs.count()
|
||||||
change_password_top10_users = qs.values(
|
change_password_top10_users = qs.values(
|
||||||
'user').annotate(user_count=Count('id')).order_by('-user_count')[:10]
|
'user').annotate(count=Count('id')).order_by('-count')[:10]
|
||||||
|
|
||||||
change_password_top10_change_bys = qs.values(
|
change_password_top10_change_bys = qs.values(
|
||||||
'change_by').annotate(user_count=Count('id')).order_by('-user_count')[:10]
|
'change_by').annotate(count=Count('id')).order_by('-count')[:10]
|
||||||
|
|
||||||
|
data['total_count_change_password'] = {
|
||||||
|
'total': total,
|
||||||
|
'user_total': qs.values('user').distinct().count(),
|
||||||
|
'change_by_total': qs.values('change_by').distinct().count(),
|
||||||
|
}
|
||||||
|
|
||||||
data['total'] = total
|
|
||||||
data['user_total'] = qs.values('user').distinct().count()
|
|
||||||
data['change_by_total'] = qs.values('change_by').distinct().count()
|
|
||||||
data['change_password_top10_users'] = list(change_password_top10_users)
|
data['change_password_top10_users'] = list(change_password_top10_users)
|
||||||
data['change_password_top10_change_bys'] = list(change_password_top10_change_bys)
|
data['change_password_top10_change_bys'] = list(change_password_top10_change_bys)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue