From 7ab521758fc315d180e701cf958e5540a1a532e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 19 Apr 2016 18:15:53 +0200 Subject: [PATCH] FIX: don't show links in PM in user summary --- app/models/user_summary.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/models/user_summary.rb b/app/models/user_summary.rb index 5af092affc4..170a5cbd1fb 100644 --- a/app/models/user_summary.rb +++ b/app/models/user_summary.rb @@ -38,9 +38,10 @@ class UserSummary def links TopicLink + .joins(:topic, :post) + .where('topics.archetype <> ?', Archetype.private_message) .where(user: @user) - .where(internal: false) - .where(reflection: false) + .where(internal: false, reflection: false, quote: false) .order('clicks DESC, created_at ASC') .limit(MAX_SUMMARY_RESULTS) end @@ -51,17 +52,14 @@ class UserSummary def most_liked_by_users likers = {} - UserAction.joins("JOIN posts ON posts.id = user_actions.target_post_id") - .joins("JOIN topics ON topics.id = posts.topic_id") - .where("posts.deleted_at IS NULL") - .where("topics.deleted_at IS NULL") - .where("topics.archetype <> '#{Archetype.private_message}'") + UserAction.joins(:target_topic, :target_post) + .where('topics.archetype <> ?', Archetype.private_message) .where(user: @user) .where(action_type: UserAction::WAS_LIKED) .group(:acting_user_id) - .order("COUNT(*) DESC") + .order('COUNT(*) DESC') .limit(MAX_SUMMARY_RESULTS) - .pluck("acting_user_id, COUNT(*)") + .pluck('acting_user_id, COUNT(*)') .each { |l| likers[l[0].to_s] = l[1] } User.where(id: likers.keys)