mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
analytics: Add summary statistic for guest users in realm.
Adds the count of users with the role of guest to the stats view `page_params` via a database query. This information is then added to the summary statistics section of the analytics page after being formatted by `stats.js`. Creates Bassanio as a guest user in the database for the analytics realm. Fixes #20162.
This commit is contained in:
committed by
Tim Abbott
parent
f37ac80384
commit
a3f6220fe4
@@ -92,6 +92,16 @@ class Command(BaseCommand):
|
||||
)
|
||||
do_change_user_role(shylock, UserProfile.ROLE_REALM_OWNER, acting_user=None)
|
||||
|
||||
# Create guest user for set_guest_users_statistic.
|
||||
create_user(
|
||||
"bassanio@analytics.ds",
|
||||
"Bassanio",
|
||||
realm,
|
||||
full_name="Bassanio",
|
||||
role=UserProfile.ROLE_GUEST,
|
||||
force_date_joined=installation_time,
|
||||
)
|
||||
|
||||
administrators_user_group = UserGroup.objects.get(
|
||||
name=UserGroup.ADMINISTRATORS_GROUP_NAME, realm=realm, is_system_group=True
|
||||
)
|
||||
|
@@ -55,11 +55,18 @@ def render_stats(
|
||||
analytics_ready: bool = True,
|
||||
) -> HttpResponse:
|
||||
assert request.user.is_authenticated
|
||||
|
||||
# Same query to get guest user count as in get_seat_count in corporate/lib/stripe.py.
|
||||
guest_users = UserProfile.objects.filter(
|
||||
realm=request.user.realm, is_active=True, is_bot=False, role=UserProfile.ROLE_GUEST
|
||||
).count()
|
||||
|
||||
page_params = dict(
|
||||
data_url_suffix=data_url_suffix,
|
||||
for_installation=for_installation,
|
||||
remote=remote,
|
||||
upload_space_used=request.user.realm.currently_used_upload_space_bytes(),
|
||||
guest_users=guest_users,
|
||||
)
|
||||
|
||||
request_language = get_and_set_request_language(
|
||||
|
Reference in New Issue
Block a user