Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

analytics: Add total messages sent summary statistic.

Lauryn Menard954b0475feb7
diff --git a/static/js/stats/stats.js b/static/js/stats/stats.js
index 6a48dc5d8c5..acad6fee6c8 100644
--- a/static/js/stats/stats.js
+++ b/static/js/stats/stats.js
@@ -122,6 +122,18 @@ function get_user_summary_statistics(data) {
$("#id_active_fifteen_day_users").closest("summary-stats").show();
}
+function get_total_messages_sent(data) {
+ if (data.length === 0) {
+ return;
+ }
+
+ const total_messages_sent = data.human.at(-1) + data.bot.at(-1);
+ const total_messages_string = total_messages_sent.toLocaleString();
+
+ $("#id_total_messages_sent").text(total_messages_string);
+ $("#id_total_messages_sent").closest("summary-stats").show();
+}
+
// PLOTLY CHARTS
function populate_messages_sent_over_time(data) {
if (data.end_times.length === 0) {
@@ -312,6 +324,7 @@ function populate_messages_sent_over_time(data) {
date_formatter = function (date) {
return format_date(date, true);
};
+ get_total_messages_sent(values);
const cumulative_traces = make_traces(dates, values, "scatter", date_formatter);
// Functions to draw and interact with the plot
diff --git a/templates/analytics/stats.html b/templates/analytics/stats.html
index e3daa21a1a2..9ca0bca47ef 100644
--- a/templates/analytics/stats.html
+++ b/templates/analytics/stats.html
@@ -26,7 +26,7 @@
<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>
-
+ <li>{{ _("Total number of messages") }}: <span id="id_total_messages_sent"></span></li>
</ul>
</div>
<div class="flex-container">