mirror of https://github.com/zulip/zulip.git
user_groups: Make get_user_group_direct_members query efficient.
This commit makes the query in get_user_group_direct_members efficient by directly fetching user-profile ids instead of first fetching user profile object and then id.
This commit is contained in:
parent
1a3d67ad0c
commit
b65aadae4b
|
@ -84,8 +84,9 @@ def create_user_group(
|
|||
|
||||
|
||||
def get_user_group_direct_members(user_group: UserGroup) -> List[UserProfile]:
|
||||
members = UserGroupMembership.objects.filter(user_group=user_group)
|
||||
return [member.user_profile.id for member in members]
|
||||
return UserGroupMembership.objects.filter(user_group=user_group).values_list(
|
||||
"user_profile_id", flat=True
|
||||
)
|
||||
|
||||
|
||||
def get_direct_memberships_of_users(user_group: UserGroup, members: List[UserProfile]) -> List[int]:
|
||||
|
|
Loading…
Reference in New Issue