From a9542776479a417e181eba70b2b29f60e0554efb Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 13 Nov 2012 13:56:32 -0500 Subject: [PATCH] get_{display,log}_recipient: Use a join query (imported from commit 1278f46655760842e21a62ca5add891515ee1945) --- zephyr/models.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zephyr/models.py b/zephyr/models.py index 5c01e1c73f..c4627b4d50 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -31,8 +31,7 @@ def get_display_recipient(recipient): stream = Stream.objects.get(id=recipient.type_id) return stream.name elif recipient.type == Recipient.HUDDLE: - user_profile_list = [UserProfile.objects.select_related().get(user=s.user_profile) for s in - Subscription.objects.filter(recipient=recipient)] + user_profile_list = UserProfile.objects.filter(subscription__recipient=recipient).select_related() return [{'email': user_profile.user.email, 'full_name': user_profile.full_name, 'short_name': user_profile.short_name} for user_profile in user_profile_list] @@ -53,8 +52,7 @@ def get_log_recipient(recipient): stream = Stream.objects.get(id=recipient.type_id) return stream.name - user_profile_list = [UserProfile.objects.select_related().get(user=s.user_profile) for s in - Subscription.objects.filter(recipient=recipient)] + user_profile_list = UserProfile.objects.filter(subscription__recipient=recipient).select_related() return [{'email': user_profile.user.email, 'full_name': user_profile.full_name, 'short_name': user_profile.short_name} for user_profile in user_profile_list]