mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Introduce Ignore user (#7072)
This commit is contained in:
committed by
Régis Hanol
parent
5c476f639c
commit
986cc8a0fb
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user