mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
realm_user_count_by_role: Use strings as dict keys.
JSON keys must be strings, and orjson enforces this. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
f8bcf39014
commit
b250e42f61
@@ -294,13 +294,13 @@ def realm_user_count(realm: Realm) -> int:
|
||||
return UserProfile.objects.filter(realm=realm, is_active=True, is_bot=False).count()
|
||||
|
||||
def realm_user_count_by_role(realm: Realm) -> Dict[str, Any]:
|
||||
human_counts = {UserProfile.ROLE_REALM_ADMINISTRATOR: 0,
|
||||
UserProfile.ROLE_REALM_OWNER: 0,
|
||||
UserProfile.ROLE_MEMBER: 0,
|
||||
UserProfile.ROLE_GUEST: 0}
|
||||
human_counts = {str(UserProfile.ROLE_REALM_ADMINISTRATOR): 0,
|
||||
str(UserProfile.ROLE_REALM_OWNER): 0,
|
||||
str(UserProfile.ROLE_MEMBER): 0,
|
||||
str(UserProfile.ROLE_GUEST): 0}
|
||||
for value_dict in list(UserProfile.objects.filter(
|
||||
realm=realm, is_bot=False, is_active=True).values('role').annotate(Count('role'))):
|
||||
human_counts[value_dict['role']] = value_dict['role__count']
|
||||
human_counts[str(value_dict['role'])] = value_dict['role__count']
|
||||
bot_count = UserProfile.objects.filter(realm=realm, is_bot=True, is_active=True).count()
|
||||
return {
|
||||
RealmAuditLog.ROLE_COUNT_HUMANS: human_counts,
|
||||
|
||||
Reference in New Issue
Block a user