X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/f0b2ed9bb6c1e153231b8088eabe6e3edcee9420..b2a3955d936b448562db9981560135cf0303a0e0:/app/controllers/changeset_controller.rb diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index fbd4417d0..329cbd79c 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -216,6 +216,12 @@ class ChangesetController < ApplicationController changesets = conditions_closed(changesets, params["closed"]) changesets = conditions_ids(changesets, params["changesets"]) + # sort and limit the changesets + changesets = changesets.order("created_at DESC").limit(100) + + # preload users, tags and comments + changesets = changesets.preload(:user, :changeset_tags, :comments) + # create the results document results = OSM::API.new.get_xml_doc @@ -351,7 +357,6 @@ class ChangesetController < ApplicationController # Find the changeset and check it is valid changeset = Changeset.find(id) - raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open? raise OSM::APIChangesetAlreadySubscribedError, changeset if changeset.subscribers.exists?(current_user.id) # Add the subscriber @@ -372,7 +377,6 @@ class ChangesetController < ApplicationController # Find the changeset and check it is valid changeset = Changeset.find(id) - raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open? raise OSM::APIChangesetNotSubscribedError, changeset unless changeset.subscribers.exists?(current_user.id) # Remove the subscriber @@ -516,13 +520,13 @@ class ChangesetController < ApplicationController times = time.split(/,/) raise OSM::APIBadUserInput, "bad time range" if times.size != 2 - from, to = times.collect { |t| DateTime.parse(t) } + from, to = times.collect { |t| Time.parse(t) } return changesets.where("closed_at >= ? and created_at <= ?", from, to) else # if there is no comma, assume its a lower limit on time - return changesets.where("closed_at >= ?", DateTime.parse(time)) + return changesets.where("closed_at >= ?", Time.parse(time)) end - # stupid DateTime seems to throw both of these for bad parsing, so + # stupid Time seems to throw both of these for bad parsing, so # we have to catch both and ensure the correct code path is taken. rescue ArgumentError => ex raise OSM::APIBadUserInput, ex.message.to_s