perf: navigation page (#9125)

Co-authored-by: feng <1304903146@qq.com>
pull/9127/head
fit2bot 2 years ago committed by GitHub
parent b2bb46a51e
commit 072c44974e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -133,47 +133,6 @@ class DatesLoginMetricMixin:
data.append(count)
return data
@lazyproperty
def dates_total_count_active_users(self):
count = len(set(self.sessions_queryset.values_list('user_id', flat=True)))
return count
@lazyproperty
def dates_total_count_inactive_users(self):
total = current_org.get_members().count()
active = self.dates_total_count_active_users
count = total - active
if count < 0:
count = 0
return count
@lazyproperty
def dates_total_count_disabled_users(self):
return current_org.get_members().filter(is_active=False).count()
@lazyproperty
def dates_total_count_active_assets(self):
return len(set(self.sessions_queryset.values_list('asset', flat=True)))
@lazyproperty
def dates_total_count_inactive_assets(self):
total = Asset.objects.all().count()
active = self.dates_total_count_active_assets
count = total - active
if count < 0:
count = 0
return count
@lazyproperty
def dates_total_count_disabled_assets(self):
return Asset.objects.filter(is_active=False).count()
def get_dates_total_count_login_users(self):
return len(set(self.sessions_queryset.values_list('user_id', flat=True)))
def get_dates_total_count_login_times(self):
return self.sessions_queryset.count()
@lazyproperty
def get_type_to_assets(self):
result = Asset.objects.annotate(type=F('platform__type')). \
@ -284,26 +243,6 @@ class IndexApi(DatesLoginMetricMixin, APIView):
'dates_metrics_total_count_active_assets': self.get_dates_metrics_total_count_active_assets(),
})
if _all or query_params.get('dates_total_count_users'):
data.update({
'dates_total_count_active_users': self.dates_total_count_active_users,
'dates_total_count_inactive_users': self.dates_total_count_inactive_users,
'dates_total_count_disabled_users': self.dates_total_count_disabled_users,
})
if _all or query_params.get('dates_total_count_assets'):
data.update({
'dates_total_count_active_assets': self.dates_total_count_active_assets,
'dates_total_count_inactive_assets': self.dates_total_count_inactive_assets,
'dates_total_count_disabled_assets': self.dates_total_count_disabled_assets,
})
if _all or query_params.get('dates_total_count'):
data.update({
'dates_total_count_login_users': self.get_dates_total_count_login_users(),
'dates_total_count_login_times': self.get_dates_total_count_login_times(),
})
if _all or query_params.get('dates_login_times_top10_assets'):
data.update({
'dates_login_times_top10_assets': self.get_dates_login_times_assets(),

Loading…
Cancel
Save