From 62c632ceefaf81edd59d92784b209e01400337b8 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 12 Feb 2013 14:00:49 -0500 Subject: [PATCH] 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) --- zephyr/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zephyr/views.py b/zephyr/views.py index 4ac95c1b38..b4da3e2e9d 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -1343,7 +1343,8 @@ def get_status_list(requesting_user_profile): return json_success({'presences': user_statuses}) 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] = \ presence_to_dict(presence)