X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/38369675b7b574c044a178d9f67ce91ed3d407c1..28b00b85da663c161803897f6a54550597ed82c1:/app/controllers/api/changesets_controller.rb diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 0dffd4de2..0a49a95f4 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -170,8 +170,15 @@ module Api changesets = conditions_closed(changesets, params["closed"]) changesets = conditions_ids(changesets, params["changesets"]) - # sort and limit the changesets - changesets = changesets.order("created_at DESC").limit(result_limit) + # sort the changesets + changesets = if params[:order] == "oldest" + changesets.order(:closed_at => :asc) + else + changesets.order(:closed_at => :desc) + end + + # limit the result + changesets = changesets.limit(result_limit) # preload users, tags and comments, and render result @changesets = changesets.preload(:user, :changeset_tags, :comments)