mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:21:23 +08:00
FIX: Ensure the top 6 categories are shown in the user summary (#12691)
Previously it would pluck 6 categories which the user had posted in, **then** order them. To select the **top 6** categories, we need to perform the ordering in the SQL query before the LIMIT
This commit is contained in:
@ -145,7 +145,7 @@ class UserSummary
|
||||
|
||||
top_categories = {}
|
||||
|
||||
Category.where(id: post_count_query.limit(MAX_SUMMARY_RESULTS).pluck('category_id'))
|
||||
Category.where(id: post_count_query.order("count(*) DESC").limit(MAX_SUMMARY_RESULTS).pluck('category_id'))
|
||||
.pluck(:id, :name, :color, :text_color, :slug, :read_restricted, :parent_category_id)
|
||||
.each do |c|
|
||||
top_categories[c[0].to_i] = CategoryWithCounts.new(
|
||||
|
Reference in New Issue
Block a user