From d24d8e4b36201ff59b304c49b32faaa2bf92d3a0 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 13 Sep 2013 13:58:58 -0400 Subject: [PATCH] Optimize showing subscribers on the settings page. If you expand subscribers on your settings page, you will now see a query like this in your postgres logs: SELECT "zerver_userprofile"."email" FROM "zerver_subscription" INNER JOIN "zerver_recipient" ON ("zerver_subscription"."recipient_id" = "zerver_recipient"."id") INNER JOIN "zerver_userprofile" ON ("zerver_subscription"."user_profile_id" = "zerver_userprofile"."id") WHERE ("zerver_recipient"."type" = 2 AND "zerver_subscription"."active" = true AND "zerver_recipient"."type_id" = 40 AND "zerver_userprofile"."is_active" = true ) The join's still complicated, but the list of fields is one instead of 40+. (imported from commit 48de1f888193a4d23fcea52d0b633d134e4a3ff7) --- zerver/lib/actions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 54f565a69f..15bc7e1cb5 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1393,7 +1393,7 @@ def gather_subscriptions(user_profile): for sub in subs: stream = stream_hash[sub.recipient.type_id] try: - subscribers = get_subscribers(stream) + subscribers = get_subscriber_emails(stream) except JsonableError: subscribers = None @@ -1409,7 +1409,7 @@ def gather_subscriptions(user_profile): 'notifications': sub.notifications, 'email_address': encode_email_address(stream)} if subscribers is not None: - stream['subscribers'] = [user.email for user in subscribers] + stream['subscribers'] = subscribers if sub.active: subscribed.append(stream) else: