]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/changeset_controller.rb
Renaming the include action to expand_bbox in the changeset controller.
[rails.git] / app / controllers / changeset_controller.rb
index e16a4e9b37a1f6fa1a537d809f7588421936163f..fad797cdc4a14ff604fc2710560c2d3efb685adb 100644 (file)
@@ -2,7 +2,6 @@
 
 class ChangesetController < ApplicationController
   require 'xml/libxml'
-  require 'diff_reader'
 
   before_filter :authorize, :only => [:create, :update, :delete, :upload, :include, :close]
   before_filter :check_write_availability, :only => [:create, :update, :delete, :upload, :include]
@@ -53,7 +52,11 @@ class ChangesetController < ApplicationController
       raise OSM::APIUserChangesetMismatchError 
     end
     
-    changeset.open = false
+    # to close the changeset, we'll just set its closed_at time to
+    # now. this might not be enough if there are concurrency issues, 
+    # but we'll have to wait and see.
+    changeset.set_closed_time_now
+
     changeset.save!
     render :nothing => true
   rescue ActiveRecord::RecordNotFound
@@ -67,7 +70,7 @@ class ChangesetController < ApplicationController
   # increase the size of the bounding box. this is a hint that clients can
   # set either before uploading a large number of changes, or changes that
   # the client (but not the server) knows will affect areas further away.
-  def include
+  def expand_bbox
     # only allow POST requests, because although this method is
     # idempotent, there is no "document" to PUT really...
     if request.post?
@@ -291,6 +294,7 @@ class ChangesetController < ApplicationController
     render ex.render_opts
   end
 
+private
   #------------------------------------------------------------
   # utility functions below.
   #------------------------------------------------------------  
@@ -361,10 +365,10 @@ class ChangesetController < ApplicationController
         raise OSM::APIBadUserInput.new("bad time range") if times.size != 2 
 
         from, to = times.collect { |t| DateTime.parse(t) }
-        return ['created_at > ? and created_at < ?', from, to]
+        return ['closed_at >= ? and created_at <= ?', from, to]
       else
         # if there is no comma, assume its a lower limit on time
-        return ['created_at > ?', DateTime.parse(time)]
+        return ['closed_at >= ?', DateTime.parse(time)]
       end
     else
       return nil
@@ -380,7 +384,7 @@ class ChangesetController < ApplicationController
   ##
   # restrict changes to those which are open
   def conditions_open(open)
-    return open.nil? ? nil : ['open = ?', true]
+    return open.nil? ? nil : ['closed_at >= ?', DateTime.now]
   end
 
 end