Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
analytics: Add summary statistics section and user statstics.
Lauryn Menard7f1a060c4d1c
diff --git a/static/js/stats/stats.js b/static/js/stats/stats.jsindex 072e2c548a7..6a48dc5d8c5 100644--- a/static/js/stats/stats.js+++ b/static/js/stats/stats.js@@ -101,6 +101,28 @@ $(() => {// Add configuration for any additional tooltips here.});+// SUMMARY STATISTICS+function get_user_summary_statistics(data) {+ if (data.length === 0) {+ return;+ }++ // Users that are not deactivated and are not bots.+ const total_users = data.all_time.at(-1);+ const total_users_string = total_users.toLocaleString();++ $("#id_total_users").text(total_users_string);+ $("#id_total_users").closest("summary-stats").show();++ // Users that have been active in the last 15 days and are not bots.+ const active_fifeteen_day_users = data._15day.at(-1);+ const active_fifteen_day_users_string = active_fifeteen_day_users.toLocaleString();++ $("#id_active_fifteen_day_users").text(active_fifteen_day_users_string);+ $("#id_active_fifteen_day_users").closest("summary-stats").show();+}++// PLOTLY CHARTSfunction populate_messages_sent_over_time(data) {if (data.end_times.length === 0) {// TODO: do something nicer here@@ -785,6 +807,7 @@ function populate_number_of_users(data) {// Initial drawing of plotdraw_or_update_plot(all_time_trace, true);$("#all_time_actives_button").addClass("selected");+ get_user_summary_statistics(data.everyone);}function populate_messages_read_over_time(data) {diff --git a/static/styles/portico/stats.css b/static/styles/portico/stats.cssindex 8c874b392c8..de4f4e0a1d7 100644--- a/static/styles/portico/stats.css+++ b/static/styles/portico/stats.css@@ -30,6 +30,20 @@ p {text-align: center;}+.summary-stats {+ vertical-align: top;+ margin: 0 auto;+ padding: 20px;+ border: 2px solid hsl(0, 0%, 93%);+ background-color: hsl(0, 0%, 100%);+ width: 395px;++ h1 {+ margin-top: 0;+ font-size: 1.5em;+ }+}+.flex-container {display: flex;flex-flow: wrap;diff --git a/templates/analytics/stats.html b/templates/analytics/stats.htmlindex 7ab843bb156..e3daa21a1a2 100644--- a/templates/analytics/stats.html+++ b/templates/analytics/stats.html@@ -21,6 +21,14 @@<div id="id_stats_errors" class="alert alert-error"></div><div class="center-charts"><h1 class="analytics-page-header">{% trans %}Zulip analytics for {{ target_name }}{% endtrans %}</h1>+ <div class="summary-stats">+ <h1>{{ _("Organization summary") }}</h1>+ <ul>+ <li>{{ _("Number of users") }}: <span id="id_total_users"></span></li>+ <li>{{ _("Users active during the last 15 days") }}: <span id="id_active_fifteen_day_users"></span></li>++ </ul>+ </div><div class="flex-container"><div class="chart-container"><h1>{{ _("Active users") }}</h1>