mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
FIX: Order result set of category search (#24027)
The previous order was too different from the logic we have on the frontend.
This commit is contained in:
parent
e31859a33a
commit
ad433daf3a
|
@ -352,12 +352,13 @@ class CategoriesController < ApplicationController
|
|||
|
||||
categories = categories.order(<<~SQL) if prioritized_category_id.present?
|
||||
CASE
|
||||
WHEN id = #{prioritized_category_id} OR parent_category_id = #{prioritized_category_id} THEN 0
|
||||
ELSE 1
|
||||
WHEN id = #{prioritized_category_id} THEN 1
|
||||
WHEN parent_category_id = #{prioritized_category_id} THEN 2
|
||||
ELSE 3
|
||||
END
|
||||
SQL
|
||||
|
||||
categories = categories.order(:read_restricted)
|
||||
categories.order(:id)
|
||||
|
||||
render json: categories, each_serializer: SiteCategorySerializer
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user