diff --git a/analytics/tests/test_activity_views.py b/analytics/tests/test_activity_views.py index 83135128a4..ad2473b7cd 100644 --- a/analytics/tests/test_activity_views.py +++ b/analytics/tests/test_activity_views.py @@ -31,7 +31,7 @@ class ActivityTest(ZulipTestCase): user_profile.is_staff = True user_profile.save(update_fields=["is_staff"]) - with self.assert_database_query_count(17): + with self.assert_database_query_count(16): result = self.client_get("/activity") self.assertEqual(result.status_code, 200) @@ -39,6 +39,10 @@ class ActivityTest(ZulipTestCase): result = self.client_get("/activity/remote") self.assertEqual(result.status_code, 200) + with self.assert_database_query_count(4): + result = self.client_get("/activity/integrations") + self.assertEqual(result.status_code, 200) + with self.assert_database_query_count(8): result = self.client_get("/realm_activity/zulip/") self.assertEqual(result.status_code, 200) diff --git a/analytics/urls.py b/analytics/urls.py index e637b0c882..c81fa4f487 100644 --- a/analytics/urls.py +++ b/analytics/urls.py @@ -4,7 +4,10 @@ from django.conf.urls import include from django.urls import path from django.urls.resolvers import URLPattern, URLResolver -from analytics.views.installation_activity import get_installation_activity +from analytics.views.installation_activity import ( + get_installation_activity, + get_integrations_activity, +) from analytics.views.realm_activity import get_realm_activity from analytics.views.remote_activity import get_remote_server_activity from analytics.views.stats import ( @@ -27,6 +30,7 @@ i18n_urlpatterns: List[Union[URLPattern, URLResolver]] = [ # Server admin (user_profile.is_staff) visible stats pages path("activity", get_installation_activity), path("activity/remote", get_remote_server_activity), + path("activity/integrations", get_integrations_activity), path("activity/support", support, name="support"), path("activity/remote/support", remote_servers_support, name="remote_servers_support"), path("realm_activity//", get_realm_activity), diff --git a/analytics/views/installation_activity.py b/analytics/views/installation_activity.py index 1c92131158..8d5410279d 100644 --- a/analytics/views/installation_activity.py +++ b/analytics/views/installation_activity.py @@ -463,8 +463,31 @@ def ad_hoc_queries() -> List[Dict[str, str]]: pages.append(get_page(query, cols, title)) - ### + return pages + +@require_server_admin +@has_request_variables +def get_installation_activity(request: HttpRequest) -> HttpResponse: + duration_content, realm_minutes = user_activity_intervals() + counts_content: str = realm_summary_table(realm_minutes) + data = [ + ("Counts", counts_content), + ("Durations", duration_content), + *((page["title"], page["content"]) for page in ad_hoc_queries()), + ] + + title = "Activity" + + return render( + request, + "analytics/activity.html", + context=dict(data=data, title=title, is_home=True), + ) + + +@require_server_admin +def get_integrations_activity(request: HttpRequest) -> HttpResponse: title = "Integrations by client" query = SQL( @@ -501,26 +524,14 @@ def ad_hoc_queries() -> List[Dict[str, str]]: "Last time", ] - pages.append(get_page(query, cols, title)) - - return pages - - -@require_server_admin -@has_request_variables -def get_installation_activity(request: HttpRequest) -> HttpResponse: - duration_content, realm_minutes = user_activity_intervals() - counts_content: str = realm_summary_table(realm_minutes) - data = [ - ("Counts", counts_content), - ("Durations", duration_content), - *((page["title"], page["content"]) for page in ad_hoc_queries()), - ] - - title = "Activity" + integrations_activity = get_page(query, cols, title) return render( request, - "analytics/activity.html", - context=dict(data=data, title=title, is_home=True), + "analytics/activity_details_template.html", + context=dict( + data=integrations_activity["content"], + title=integrations_activity["title"], + is_home=False, + ), ) diff --git a/templates/analytics/realm_summary_table.html b/templates/analytics/realm_summary_table.html index 30106ae42a..e1cd5b208d 100644 --- a/templates/analytics/realm_summary_table.html +++ b/templates/analytics/realm_summary_table.html @@ -6,6 +6,7 @@

Counts chart key: