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

@ -91,7 +91,9 @@ SELECT
coalesce(p.post_number, 1) post_number,
p.reply_to_post_number,
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.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,
CASE WHEN coalesce(p.deleted_at, p2.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted,
p.hidden,
@ -139,7 +141,9 @@ SELECT
coalesce(p.post_number, 1) post_number,
p.reply_to_post_number,
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.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,
CASE WHEN coalesce(p.deleted_at, t.deleted_at) IS NULL THEN false ELSE true END deleted,
p.hidden,

View file

@ -23,17 +23,26 @@ class UserActionSerializer < ApplicationSerializer
:hidden,
:moderator_action
def excerpt
PrettyText.excerpt(object.cooked,300) if object.cooked
end
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
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
def slug