mirror of https://github.com/jumpserver/jumpserver
perf: Account automation report
parent
96020fa6b4
commit
c1c5025fbb
|
@ -145,7 +145,7 @@ only_system_permissions = (
|
|||
('rbac', 'orgrole', 'delete,add,change', 'orgrole'),
|
||||
('orgs', 'organization', '*', '*'),
|
||||
('xpack', 'license', '*', '*'),
|
||||
('settings', 'setting', '*', '*'),
|
||||
('settings', 'setting', 'add,change,delete', '*'),
|
||||
('tickets', '*', '*', '*'),
|
||||
('ops', 'celerytask', 'view', 'taskmonitor'),
|
||||
('terminal', 'terminal', '*', '*'),
|
||||
|
|
|
@ -33,6 +33,7 @@ view_nodes_data = [
|
|||
app_nodes_data = [
|
||||
{'id': 'users', 'view': 'view_console'},
|
||||
{'id': 'assets', 'view': 'view_console'},
|
||||
{'id': 'accounts', 'name': _('Accounts'), 'view': 'view_console'},
|
||||
{'id': 'perms', 'view': 'view_console'},
|
||||
{'id': 'terminal', 'name': _('Session audits'), 'view': 'view_audit'},
|
||||
{'id': 'audits', 'view': 'view_audit'},
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from django.http import JsonResponse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework.views import APIView
|
||||
|
||||
|
@ -45,15 +46,19 @@ class AccountAutomationApi(DateRangeMixin, APIView):
|
|||
|
||||
def get_execution_metrics(self):
|
||||
executions = AutomationExecution.objects.filter(type__in=AutomationTypes.values)
|
||||
filtered_queryset = self.filter_by_date_range(executions, 'date_start')
|
||||
qs = self.filter_by_date_range(executions, 'date_start')
|
||||
|
||||
types = set()
|
||||
data = defaultdict(lambda: defaultdict(int))
|
||||
for t, tp in filtered_queryset.values_list('date_start', 'type'):
|
||||
for obj in qs:
|
||||
tp = obj.type
|
||||
if not tp:
|
||||
continue
|
||||
types.add(tp)
|
||||
date_str = str(t.date())
|
||||
|
||||
dt = obj.date_start
|
||||
dt_local = timezone.localtime(dt)
|
||||
date_str = str(dt_local.date())
|
||||
data[date_str][tp] += 1
|
||||
|
||||
tp_map = defaultdict(list)
|
||||
|
|
|
@ -63,8 +63,6 @@ class UserReportApi(DateRangeMixin, APIView):
|
|||
|
||||
for obj in qs:
|
||||
dt = obj.datetime
|
||||
if dt is None:
|
||||
continue
|
||||
dt_local = timezone.localtime(dt)
|
||||
hour = dt_local.hour
|
||||
metrics[buckets[hour // 6]] += 1
|
||||
|
|
Loading…
Reference in New Issue