From 4ee7a3a64499ba3b205f095ecddb60deebeb8b48 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 20 Aug 2023 01:56:15 -0700 Subject: [PATCH] Order search results by release or update date (#123) The list of all items that shows up when you open the search modal will now list all items sorted latest first, whether the item is brand new or an item that recently got an uncap. --- app/controllers/api/v1/search_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index d18b69d..37731bd 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -72,7 +72,7 @@ module Api Character.en_search(search_params[:query]).where(conditions) end else - Character.where(conditions) + Character.where(conditions).order(Arel.sql('greatest(release_date, flb_date, ulb_date) desc')) end count = characters.length @@ -110,7 +110,7 @@ module Api Weapon.en_search(search_params[:query]).where(conditions) end else - Weapon.where(conditions) + Weapon.where(conditions).order(Arel.sql('greatest(release_date, flb_date, ulb_date) desc')) end count = weapons.length @@ -143,7 +143,7 @@ module Api Summon.en_search(search_params[:query]).where(conditions) end else - Summon.where(conditions) + Summon.where(conditions).order(release_date: :desc).order(Arel.sql('greatest(release_date, flb_date, ulb_date, xlb_date) desc')) end count = summons.length