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: Display org_type on /activity.

Eeshan Garg434c262365ec
diff --git a/analytics/views/installation_activity.py b/analytics/views/installation_activity.py
index dc0e8a50553..e11d1b33d44 100644
--- a/analytics/views/installation_activity.py
+++ b/analytics/views/installation_activity.py
@@ -22,7 +22,7 @@ from analytics.views.activity_common import (
realm_stats_link,
remote_installation_stats_link,
)
-from analytics.views.support import get_plan_name
+from analytics.views.support import get_org_type_display_name, get_plan_name
from zerver.decorator import require_server_admin
from zerver.lib.request import has_request_variables
from zerver.lib.timestamp import timestamp_to_datetime
@@ -102,6 +102,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
realm.string_id,
realm.date_created,
realm.plan_type,
+ realm.org_type,
coalesce(wau_table.value, 0) wau_count,
coalesce(dau_table.value, 0) dau_count,
coalesce(user_count_table.value, 0) user_profile_count,
@@ -233,6 +234,9 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
total_arr += sum(estimated_arrs.values())
+ for row in rows:
+ row["org_type_string"] = get_org_type_display_name(row["org_type"])
+
# augment data with realm_minutes
total_hours = 0.0
for row in rows:
@@ -271,6 +275,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
total_row = dict(
string_id="Total",
plan_type_string="",
+ org_type_string="",
effective_rate="",
arr=total_arr,
stats_link="",
diff --git a/analytics/views/support.py b/analytics/views/support.py
index d7760a3883b..df900da40fe 100644
--- a/analytics/views/support.py
+++ b/analytics/views/support.py
@@ -28,7 +28,14 @@ from zerver.lib.actions import (
from zerver.lib.exceptions import JsonableError
from zerver.lib.realm_icon import realm_icon_url
from zerver.lib.subdomains import get_subdomain_from_hostname
-from zerver.models import MultiuseInvite, PreregistrationUser, Realm, UserProfile, get_realm
+from zerver.models import (
+ MultiuseInvite,
+ PreregistrationUser,
+ Realm,
+ UserProfile,
+ get_org_type_display_name,
+ get_realm,
+)
from zerver.views.invite import get_invitee_emails_set
if settings.BILLING_ENABLED:
diff --git a/templates/analytics/realm_summary_table.html b/templates/analytics/realm_summary_table.html
index abcbb21bd7b..07c3248a177 100644
--- a/templates/analytics/realm_summary_table.html
+++ b/templates/analytics/realm_summary_table.html
@@ -25,6 +25,7 @@
<th>Created (green if ≤12wk)</th>
{% if billing_enabled %}
<th>Plan type</th>
+ <th>Org type</th>
<th>ARR</th>
<th>Rate (%)</th>
{% endif %}
@@ -58,7 +59,13 @@
<td>
{{ row.plan_type_string }}
</td>
+ {% endif %}
+ <td>
+ {{ row.org_type_string }}
+ </td>
+
+ {% if billing_enabled %}
<td class="number">
{% if row.arr %}
{{ row.arr }}
diff --git a/zerver/models.py b/zerver/models.py
index 0e889296951..fc39eb4e033 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -858,6 +858,14 @@ def avatar_changes_disabled(realm: Realm) -> bool:
return settings.AVATAR_CHANGES_DISABLED or realm.avatar_changes_disabled
+def get_org_type_display_name(org_type: int) -> str:
+ for realm_type, realm_type_details in Realm.ORG_TYPES.items():
+ if realm_type_details["id"] == org_type:
+ return realm_type_details["name"]
+
+ return ""
+
+
class RealmDomain(models.Model):
"""For an organization with emails_restricted_to_domains enabled, the list of
allowed domains"""