From f0512e91e0cfe584505142c979d1f07434081b06 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 11 Oct 2013 15:32:30 -0400 Subject: [PATCH] Split out bot counts (imported from commit 2e5afae98a28774f555c45019ebbba778160962b) --- templates/zerver/realm_summary_table.html | 6 ++++++ zerver/views/__init__.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/templates/zerver/realm_summary_table.html b/templates/zerver/realm_summary_table.html index 301eadd48d..86545bbff0 100644 --- a/templates/zerver/realm_summary_table.html +++ b/templates/zerver/realm_summary_table.html @@ -7,6 +7,7 @@ Domain Active users Total users + Bots Hours @@ -32,6 +33,11 @@ {{ row.user_profile_count }} + {# Bots #} + + {{ row.bot_count }} + + {# Hours #} {{ row.hours }} diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index a9acca0e6c..02a1640b05 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -1879,7 +1879,16 @@ def realm_summary_table(realm_minutes): FROM zerver_userprofile up WHERE up.realm_id = realm.id AND is_active - ) user_profile_count + AND not is_bot + ) user_profile_count, + ( + SELECT + count(*) + FROM zerver_userprofile up + WHERE up.realm_id = realm.id + AND is_active + AND is_bot + ) bot_count FROM zerver_realm realm LEFT OUTER JOIN ( @@ -1936,14 +1945,17 @@ def realm_summary_table(realm_minutes): # create totals total_active_user_count = 0 total_user_profile_count = 0 + total_bot_count = 0 for row in rows: total_active_user_count += int(row['active_user_count']) total_user_profile_count += int(row['user_profile_count']) + total_bot_count += int(row['bot_count']) rows.append(dict( domain='Total', active_user_count=total_active_user_count, user_profile_count=total_user_profile_count, + bot_count=total_bot_count, hours=int(total_hours) ))