From: Tom Hughes Date: Sun, 13 Aug 2023 18:09:54 +0000 (+0100) Subject: Sort changesets by close time to match selection X-Git-Tag: live~706 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/702c071e191e0c79537f2e68f1084aa42bcb3c7a?hp=f0590458484a5bb9a63e549303df7275cf58a69b Sort changesets by close time to match selection This ensures that the sort can be optimised using the index when selecting by time. --- diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 660140427..0a49a95f4 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -172,9 +172,9 @@ module Api # sort the changesets changesets = if params[:order] == "oldest" - changesets.order("created_at ASC") + changesets.order(:closed_at => :asc) else - changesets.order("created_at DESC") + changesets.order(:closed_at => :desc) end # limit the result