From e60c92957d0b9b06db84de0f54f849d1096d0d1e Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 30 Mar 2023 15:33:01 +0200 Subject: [PATCH] fix(manager): don't break DS by sorting Dossier by created_at --- app/controllers/manager/application_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/manager/application_controller.rb b/app/controllers/manager/application_controller.rb index f529fa7cf..195f36d03 100644 --- a/app/controllers/manager/application_controller.rb +++ b/app/controllers/manager/application_controller.rb @@ -5,7 +5,7 @@ module Manager def default_params request.query_parameters[resource_name] ||= { - order: "created_at", + order: "id", direction: "desc" } end @@ -24,6 +24,15 @@ module Manager private + def sorting_attribute + attribute = super + + # do not sort by non-indexed created_at. This require a full table scan, locking every other transactions. + return :id if attribute.to_sym == :created_at + + attribute + end + # private method called by rails fwk # see https://github.com/roidrage/lograge def append_info_to_payload(payload)