FIX: frequent posters wasn't displaying the correct information
This commit is contained in:
parent
469c6776c6
commit
47e79570cc
|
@ -277,19 +277,21 @@ class TopicView
|
||||||
|
|
||||||
def post_counts_by_user
|
def post_counts_by_user
|
||||||
@post_counts_by_user ||= begin
|
@post_counts_by_user ||= begin
|
||||||
return {} if @posts.blank?
|
post_ids = unfiltered_posts.pluck(:id)
|
||||||
|
|
||||||
|
return {} if post_ids.blank?
|
||||||
|
|
||||||
sql = <<~SQL
|
sql = <<~SQL
|
||||||
SELECT user_id, count(*) AS count_all
|
SELECT user_id, count(*) AS count_all
|
||||||
FROM posts
|
FROM posts
|
||||||
WHERE id IN (:post_ids)
|
WHERE id IN (:post_ids)
|
||||||
AND user_id IS NOT NULL
|
AND user_id IS NOT NULL
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
ORDER BY count_all DESC
|
ORDER BY count_all DESC
|
||||||
LIMIT 24
|
LIMIT 24
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
Hash[Post.exec_sql(sql, post_ids: @posts.pluck(:id)).values]
|
Hash[Post.exec_sql(sql, post_ids: post_ids).values]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue