FIX: don't show top links from private categories in user summary

This commit is contained in:
Régis Hanol 2016-05-02 15:26:23 +02:00
parent 4141cfc716
commit e2928f78d2
2 changed files with 5 additions and 7 deletions

View file

@ -139,14 +139,12 @@ class Topic < ActiveRecord::Base
# Query conditions
condition = if ids.present?
["NOT c.read_restricted or c.id in (:cats)", cats: ids]
["NOT read_restricted OR id IN (:cats)", cats: ids]
else
["NOT c.read_restricted"]
["NOT read_restricted"]
end
where("category_id IS NULL OR category_id IN (
SELECT c.id FROM categories c
WHERE #{condition[0]})", condition[1])
where("topics.category_id IS NULL OR topics.category_id IN (SELECT id FROM categories WHERE #{condition[0]})", condition[1])
}
attr_accessor :ignore_category_auto_close

View file

@ -30,7 +30,6 @@ class UserSummary
.merge(Topic.listable_topics.visible.secured(@guardian))
.where(user: @user)
.where('post_number > 1')
.where('topics.archetype <> ?', Archetype.private_message)
.order('posts.like_count DESC, posts.created_at ASC')
.limit(MAX_SUMMARY_RESULTS)
end
@ -39,7 +38,8 @@ class UserSummary
TopicLink
.joins(:topic, :post)
.includes(:topic, :post)
.where('topics.archetype <> ?', Archetype.private_message)
.where('posts.post_type IN (?)', Topic.visible_post_types(@guardian && @guardian.user))
.merge(Topic.listable_topics.visible.secured(@guardian))
.where(user: @user)
.where(internal: false, reflection: false, quote: false)
.order('clicks DESC, topic_links.created_at ASC')