Rename minimal parameter to basic
This commit is contained in:
parent
069b218828
commit
7f60b3abff
@ -19,7 +19,7 @@ class DashboardApiView(ApiTokenRequiredMixin, DateRangeMixin, View):
|
|||||||
if uuid:
|
if uuid:
|
||||||
services = services.filter(uuid=uuid)
|
services = services.filter(uuid=uuid)
|
||||||
|
|
||||||
minimal = request.GET.get('minimal', '0').lower() in ('1', 'true')
|
basic = request.GET.get('basic', '0').lower() in ('1', 'true')
|
||||||
start = self.get_start_date()
|
start = self.get_start_date()
|
||||||
end = self.get_end_date()
|
end = self.get_end_date()
|
||||||
services_data = [
|
services_data = [
|
||||||
@ -27,12 +27,12 @@ class DashboardApiView(ApiTokenRequiredMixin, DateRangeMixin, View):
|
|||||||
'name': s.name,
|
'name': s.name,
|
||||||
'uuid': s.uuid,
|
'uuid': s.uuid,
|
||||||
'link': s.link,
|
'link': s.link,
|
||||||
'stats': s.get_core_stats(start, end, minimal),
|
'stats': s.get_core_stats(start, end, basic),
|
||||||
}
|
}
|
||||||
for s in services
|
for s in services
|
||||||
]
|
]
|
||||||
|
|
||||||
if not minimal:
|
if not basic:
|
||||||
services_data = self._convert_querysets_to_lists(services_data)
|
services_data = self._convert_querysets_to_lists(services_data)
|
||||||
|
|
||||||
return JsonResponse(data={'services': services_data})
|
return JsonResponse(data={'services': services_data})
|
||||||
|
@ -113,21 +113,21 @@ class Service(models.Model):
|
|||||||
start_time=timezone.now() - timezone.timedelta(days=1)
|
start_time=timezone.now() - timezone.timedelta(days=1)
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_core_stats(self, start_time=None, end_time=None, minimal=False):
|
def get_core_stats(self, start_time=None, end_time=None, basic=False):
|
||||||
if start_time is None:
|
if start_time is None:
|
||||||
start_time = timezone.now() - timezone.timedelta(days=30)
|
start_time = timezone.now() - timezone.timedelta(days=30)
|
||||||
if end_time is None:
|
if end_time is None:
|
||||||
end_time = timezone.now()
|
end_time = timezone.now()
|
||||||
|
|
||||||
main_data = self.get_relative_stats(start_time, end_time, minimal)
|
main_data = self.get_relative_stats(start_time, end_time, basic)
|
||||||
comparison_data = self.get_relative_stats(
|
comparison_data = self.get_relative_stats(
|
||||||
start_time - (end_time - start_time), start_time, minimal
|
start_time - (end_time - start_time), start_time, basic
|
||||||
)
|
)
|
||||||
main_data["compare"] = comparison_data
|
main_data["compare"] = comparison_data
|
||||||
|
|
||||||
return main_data
|
return main_data
|
||||||
|
|
||||||
def get_relative_stats(self, start_time, end_time, minimal=False):
|
def get_relative_stats(self, start_time, end_time, basic=False):
|
||||||
Session = apps.get_model("analytics", "Session")
|
Session = apps.get_model("analytics", "Session")
|
||||||
Hit = apps.get_model("analytics", "Hit")
|
Hit = apps.get_model("analytics", "Hit")
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class Service(models.Model):
|
|||||||
avg_hits_per_session = hit_count / session_count if session_count > 0 else None
|
avg_hits_per_session = hit_count / session_count if session_count > 0 else None
|
||||||
|
|
||||||
avg_session_duration = self._get_avg_session_duration(sessions, session_count)
|
avg_session_duration = self._get_avg_session_duration(sessions, session_count)
|
||||||
if minimal:
|
if basic:
|
||||||
return {
|
return {
|
||||||
"currently_online": currently_online,
|
"currently_online": currently_online,
|
||||||
"session_count": session_count,
|
"session_count": session_count,
|
||||||
|
Loading…
Reference in New Issue
Block a user