mirror of https://github.com/zulip/zulip.git
users: Pass realm as arg to select_related in fetch_users_by_id.
This commit updates select_related call to pass "realm" as argument in select_related call in fetch_users_by_id function as we only require realm for the UserProfile objects fetched using fetch_users_by_id. Also, note that "realm" is the only non-null foreign key field in UserProfile object, so select_related() was only fetching realm object previously as well. But we should still pass "realm" as argument in select_related call so that we can make sure that only required fields are selected in case we add more foreign keys to UserProfile in future.
This commit is contained in:
parent
bb3945a32f
commit
c0029319f9
|
@ -223,7 +223,7 @@ def user_ids_to_users(user_ids: Sequence[int], realm: Realm) -> List[UserProfile
|
|||
# users should be included.
|
||||
|
||||
def fetch_users_by_id(user_ids: List[int]) -> List[UserProfile]:
|
||||
return list(UserProfile.objects.filter(id__in=user_ids).select_related())
|
||||
return list(UserProfile.objects.filter(id__in=user_ids).select_related("realm"))
|
||||
|
||||
user_profiles_by_id: Dict[int, UserProfile] = bulk_cached_fetch(
|
||||
cache_key_function=user_profile_by_id_cache_key,
|
||||
|
|
Loading…
Reference in New Issue