presence: Fix loop making database queries.

The previous select_related didn't properly get the User object,
containing the email address, and thus would make one query per user
with presernce information.

(imported from commit 3341bc5a65387030fa8737b03ca43f79089ef56b)
This commit is contained in:
Tim Abbott 2013-02-12 14:00:49 -05:00
parent 7e09166f45
commit 62c632ceef
1 changed files with 2 additions and 1 deletions

View File

@ -1343,7 +1343,8 @@ def get_status_list(requesting_user_profile):
return json_success({'presences': user_statuses}) return json_success({'presences': user_statuses})
for presence in UserPresence.objects.filter( for presence in UserPresence.objects.filter(
user_profile__realm=requesting_user_profile.realm).select_related('user_profile', 'client'): user_profile__realm=requesting_user_profile.realm).select_related(
'user_profile', 'user_profile__user', 'client'):
user_statuses[presence.user_profile.user.email][presence.client.name] = \ user_statuses[presence.user_profile.user.email][presence.client.name] = \
presence_to_dict(presence) presence_to_dict(presence)