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:
Sahil Batra
2025-09-10 12:54:33 +05:30
committed by Tim Abbott
parent d4d7a8fe2a
commit 764f4aa2e0
42 changed files with 573 additions and 436 deletions

View File

@@ -88,10 +88,10 @@ class Command(ZulipBaseCommand):
)
owners_system_group = NamedUserGroup.objects.get(
name=SystemGroups.OWNERS, realm=realm, is_system_group=True
name=SystemGroups.OWNERS, realm_for_sharding=realm, is_system_group=True
)
guests_system_group = NamedUserGroup.objects.get(
name=SystemGroups.EVERYONE, realm=realm, is_system_group=True
name=SystemGroups.EVERYONE, realm_for_sharding=realm, is_system_group=True
)
shylock = create_user(