mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 19:43:47 +00:00
groups: Use realm_for_sharding for limiting NamedUserGroup queries.
For get and filter queries of NamedUserGroup, realm_for_sharding field is used instead of realm field, as directly using realm_for_sharding field on NamedUserGroup makes the query faster than using realm present on the base UserGroup table.
This commit is contained in:
@@ -178,6 +178,6 @@ class GroupGroupMembership(models.Model):
|
||||
@cache_with_key(get_realm_system_groups_cache_key, timeout=3600 * 24 * 7)
|
||||
def get_realm_system_groups_name_dict(realm_id: int) -> dict[int, str]:
|
||||
system_groups = NamedUserGroup.objects.filter(
|
||||
realm_id=realm_id, is_system_group=True
|
||||
realm_for_sharding_id=realm_id, is_system_group=True
|
||||
).values_list("id", "name")
|
||||
return dict(system_groups)
|
||||
|
||||
Reference in New Issue
Block a user