Merge pull request #1331 from ZogStriP/fix-avatars-on-activity-stream

FIX: performance regression on activity streams
This commit is contained in:
Sam 2013-08-14 16:52:13 -07:00
commit 1965cbcad6
2 changed files with 18 additions and 5 deletions

View file

@ -90,8 +90,10 @@ SELECT
a.user_id AS target_user_id, au.name AS target_name, au.username AS target_username, a.user_id AS target_user_id, au.name AS target_name, au.username AS target_username,
coalesce(p.post_number, 1) post_number, coalesce(p.post_number, 1) post_number,
p.reply_to_post_number, p.reply_to_post_number,
pu.email ,pu.username, pu.name, pu.id user_id, pu.email, pu.username, pu.name, pu.id user_id,
pu.use_uploaded_avatar, pu.uploaded_avatar_template, pu.uploaded_avatar_id,
u.email acting_email, u.username acting_username, u.name acting_name, u.id acting_user_id, u.email acting_email, u.username acting_username, u.name acting_name, u.id acting_user_id,
u.use_uploaded_avatar acting_use_uploaded_avatar, u.uploaded_avatar_template acting_uploaded_avatar_template, u.uploaded_avatar_id acting_uploaded_avatar_id,
coalesce(p.cooked, p2.cooked) cooked, coalesce(p.cooked, p2.cooked) cooked,
CASE WHEN coalesce(p.deleted_at, p2.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted, CASE WHEN coalesce(p.deleted_at, p2.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted,
p.hidden, p.hidden,
@ -138,8 +140,10 @@ SELECT
:user_id AS target_user_id, au.name AS target_name, au.username AS target_username, :user_id AS target_user_id, au.name AS target_name, au.username AS target_username,
coalesce(p.post_number, 1) post_number, coalesce(p.post_number, 1) post_number,
p.reply_to_post_number, p.reply_to_post_number,
pu.email ,pu.username, pu.name, pu.id user_id, pu.email, pu.username, pu.name, pu.id user_id,
pu.use_uploaded_avatar, pu.uploaded_avatar_template, pu.uploaded_avatar_id,
pu.email acting_email, pu.username acting_username, pu.name acting_name, pu.id acting_user_id, pu.email acting_email, pu.username acting_username, pu.name acting_name, pu.id acting_user_id,
pu.use_uploaded_avatar acting_use_uploaded_avatar, pu.uploaded_avatar_template acting_uploaded_avatar_template, pu.uploaded_avatar_id acting_uploaded_avatar_id,
p.cooked, p.cooked,
CASE WHEN coalesce(p.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted, CASE WHEN coalesce(p.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted,
p.hidden, p.hidden,

View file

@ -23,17 +23,26 @@ class UserActionSerializer < ApplicationSerializer
:hidden, :hidden,
:moderator_action :moderator_action
def excerpt def excerpt
PrettyText.excerpt(object.cooked,300) if object.cooked PrettyText.excerpt(object.cooked,300) if object.cooked
end end
def avatar_template def avatar_template
User.avatar_template(object.email) user = User.new
user[:email] = object.email
user[:use_uploaded_avatar] = object.use_uploaded_avatar
user[:uploaded_avatar_template] = object.uploaded_avatar_template
user[:uploaded_avatar_id] = object.uploaded_avatar_id
user.avatar_template
end end
def acting_avatar_template def acting_avatar_template
User.avatar_template(object.acting_email) acting_user = User.new
acting_user[:email] = object.acting_email
acting_user[:use_uploaded_avatar] = object.acting_use_uploaded_avatar
acting_user[:uploaded_avatar_template] = object.acting_uploaded_avatar_template
acting_user[:uploaded_avatar_id] = object.acting_uploaded_avatar_id
acting_user.avatar_template
end end
def slug def slug