X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c65f808244a5042c5b437b5f3ea8dcc6d8513002..b350c78bc8740701a57d8639da5ab012a51f70c7:/app/controllers/api/changesets_controller.rb diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 0dffd4de2..8a1b9f55b 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(:created_at => :asc) + else + changesets.order(:created_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)