FEATURE: Introduce Ignore user (#7072)

This commit is contained in:
Tarek Khalil
2019-02-27 13:49:07 +00:00
committed by Régis Hanol
parent 5c476f639c
commit 986cc8a0fb
16 changed files with 233 additions and 25 deletions

View File

@@ -330,13 +330,13 @@ class TopicView
return {} if post_ids.blank?
sql = <<~SQL
SELECT user_id, count(*) AS count_all
FROM posts
WHERE id in (:post_ids)
AND user_id IS NOT NULL
GROUP BY user_id
ORDER BY count_all DESC
LIMIT #{MAX_PARTICIPANTS}
SELECT user_id, count(*) AS count_all
FROM posts
WHERE id in (:post_ids)
AND user_id IS NOT NULL
GROUP BY user_id
ORDER BY count_all DESC
LIMIT #{MAX_PARTICIPANTS}
SQL
Hash[*DB.query_single(sql, post_ids: post_ids)]
@@ -515,22 +515,22 @@ class TopicView
def get_sort_order(post_number)
sql = <<~SQL
SELECT posts.sort_order
FROM posts
WHERE posts.post_number = #{post_number.to_i}
AND posts.topic_id = #{@topic.id.to_i}
LIMIT 1
SELECT posts.sort_order
FROM posts
WHERE posts.post_number = #{post_number.to_i}
AND posts.topic_id = #{@topic.id.to_i}
LIMIT 1
SQL
sort_order = DB.query_single(sql).first
if !sort_order
sql = <<~SQL
SELECT posts.sort_order
FROM posts
WHERE posts.topic_id = #{@topic.id.to_i}
ORDER BY @(post_number - #{post_number.to_i})
LIMIT 1
SELECT posts.sort_order
FROM posts
WHERE posts.topic_id = #{@topic.id.to_i}
ORDER BY @(post_number - #{post_number.to_i})
LIMIT 1
SQL
sort_order = DB.query_single(sql).first
@@ -602,6 +602,12 @@ class TopicView
@contains_gaps = false
@filtered_posts = unfiltered_posts
if SiteSetting.ignore_user_enabled
@filtered_posts = @filtered_posts.where.not("user_id IN (?) AND id <> ?",
IgnoredUser.where(user_id: @user.id).select(:ignored_user_id),
first_post_id)
end
# Filters
if @filter == 'summary'
@filtered_posts = @filtered_posts.summary(@topic.id)