]> git.openstreetmap.org Git - rails.git/commitdiff
Sort changesets by close time to match selection
authorTom Hughes <tom@compton.nu>
Sun, 13 Aug 2023 18:09:54 +0000 (19:09 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 13 Aug 2023 18:09:54 +0000 (19:09 +0100)
This ensures that the sort can be optimised using the index
when selecting by time.

app/controllers/api/changesets_controller.rb

index 66014042718126ceca06b3bd3f864a7bb6985be6..0a49a95f4e01e98a99c07566f6da92282448e09b 100644 (file)
@@ -172,9 +172,9 @@ module Api
 
       # sort the changesets
       changesets = if params[:order] == "oldest"
 
       # sort the changesets
       changesets = if params[:order] == "oldest"
-                     changesets.order("created_at ASC")
+                     changesets.order(:closed_at => :asc)
                    else
                    else
-                     changesets.order("created_at DESC")
+                     changesets.order(:closed_at => :desc)
                    end
 
       # limit the result
                    end
 
       # limit the result