zulip/zerver/models
Sahil Batra e23af20079 realm: Prefetch group settings only for "/register" response.
This commit updates code to prefetch realm group settings like
"can_create_public_channel_group" only when computing settings
for "/register" response by refetching the realm object with
select_related instead of fetching those settings in UserProfile
query.

This change is done because we do not need to prefetch these
settings for every UserProfile object and for most of the cases
where these settings are actually accessed, we can afford extra
query like when checking permission to create streams. But we
cannot afford one query extra for each setting when computing
these settings for "/register" response, so we re-fetch the
realm object with select_related leading to only one extra
query.

The query count changes in tests are -
- Query count increases by 1 when calling fetch_initial_state_data
for computing can_create_public_streams because Realm object from
UserProfile does not have prefetched setting fields.

- Query count increases by one in test_subs where streams are
created which is as expected due to the setting not being prefetched.

- Query count increases by 2 in tests in test_home.py where one
query is to refetch the realm object and one for computing
can_create_public_streams as mentioned above.
2024-06-16 11:55:28 -07:00
..
__init__.py user_groups: Create NamedUserGroup objects when creating new groups. 2024-04-26 17:03:09 -07:00
alert_words.py models: Extract zerver.models.alert_words. 2023-12-16 22:08:44 -08:00
bots.py models: Extract zerver.models.bots. 2023-12-16 22:08:44 -08:00
clients.py models: Migrate ids of all non-Message-related tables to bigint. 2024-06-05 11:48:27 -07:00
constants.py
custom_profile_fields.py custom_profile_fields: Add "required" parameter to the profile fields. 2024-03-21 10:48:54 -07:00
drafts.py models: Extract zerver.models.drafts. 2023-12-16 22:08:44 -08:00
groups.py user_groups: Remove unneeded fields from UserGroup model. 2024-04-26 17:03:09 -07:00
linkifiers.py models: Extract zerver.models.linkifiers. 2023-12-16 22:08:44 -08:00
lookups.py models: Extract zerver.models.lookups. 2023-12-16 22:08:44 -08:00
messages.py models: Add message type field. 2024-06-10 13:34:23 -07:00
muted_users.py models: Extract zerver.models.muted_users. 2023-12-16 22:08:44 -08:00
onboarding_steps.py models: Extract zerver.models.onboarding_steps. 2023-12-16 22:08:44 -08:00
prereg_users.py invites: Add include_realm_default_subscriptions parameter. 2024-05-14 14:20:07 -07:00
presence.py presence: Backend implementation of the last_update_id API. 2024-06-06 17:25:54 -07:00
push_notifications.py models: Extract zerver.models.push_notifications. 2023-12-16 22:08:44 -08:00
realm_audit_logs.py zerver: Add a partial audit log index for counting active users. 2024-06-03 12:35:35 -07:00
realm_emoji.py models: Extract zerver.models.realm_emoji. 2023-12-16 22:08:44 -08:00
realm_playgrounds.py models: Extract zerver.models.realm_playgrounds. 2023-12-16 22:08:44 -08:00
realms.py realm: Prefetch group settings only for "/register" response. 2024-06-16 11:55:28 -07:00
recipients.py models: Migrate ids of all non-Message-related tables to bigint. 2024-06-05 11:48:27 -07:00
scheduled_jobs.py mention: Use NamedUserGroup objects in mention code. 2024-04-26 17:03:09 -07:00
streams.py left_sidebar: Rename "more topics" to "all topics". 2024-06-04 10:18:54 -07:00
user_activity.py models: Migrate ids of all non-Message-related tables to bigint. 2024-06-05 11:48:27 -07:00
user_topics.py models: Extract zerver.models.user_topics. 2023-12-16 22:08:44 -08:00
users.py realm: Prefetch group settings only for "/register" response. 2024-06-16 11:55:28 -07:00