From ad433daf3ac49bd730cb30787bfd4e952f4a9e42 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 19 Oct 2023 20:28:23 +0300 Subject: [PATCH] FIX: Order result set of category search (#24027) The previous order was too different from the logic we have on the frontend. --- app/controllers/categories_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 10baa4cce6d..5d6086d0e41 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -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