mirror of https://github.com/zulip/zulip.git
dev_login: Pass realm as arg to select_related calls.
This commit updates the select_related calls in queries to get UserProfile objects in dev_login code to pass "realm" as argument to select_related call. 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
62f01edee3
commit
3ae0b4f913
|
@ -30,11 +30,13 @@ def get_dev_users(realm: Optional[Realm] = None, extra_users_count: int = 10) ->
|
|||
# it still makes sense to limit how many extra users we render to
|
||||
# support performance testing with DevAuthBackend.
|
||||
if realm is not None:
|
||||
users_query = UserProfile.objects.select_related().filter(
|
||||
users_query = UserProfile.objects.select_related("realm").filter(
|
||||
is_bot=False, is_active=True, realm=realm
|
||||
)
|
||||
else:
|
||||
users_query = UserProfile.objects.select_related().filter(is_bot=False, is_active=True)
|
||||
users_query = UserProfile.objects.select_related("realm").filter(
|
||||
is_bot=False, is_active=True
|
||||
)
|
||||
|
||||
shakespearian_users = users_query.exclude(email__startswith="extrauser").order_by("email")
|
||||
extra_users = users_query.filter(email__startswith="extrauser").order_by("email")
|
||||
|
|
Loading…
Reference in New Issue