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)
This commit is contained in:
Steve Howell 2013-09-13 13:58:58 -04:00
parent 9cdedf7e6c
commit d24d8e4b36
1 changed files with 2 additions and 2 deletions

View File

@ -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: