]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/changeset_controller.rb
Merge remote-tracking branch 'openstreetmap/pull/1085'
[rails.git] / app / controllers / changeset_controller.rb
index e0d75985d423ddedae3351246dc006dd3c04a911..733c20922b72c332cb59559b798a4ea911647a72 100644 (file)
@@ -15,6 +15,7 @@ class ChangesetController < ApplicationController
   before_action :check_api_readable, :except => [:create, :update, :delete, :upload, :download, :query, :list, :feed, :comment, :subscribe, :unsubscribe, :comments_feed]
   before_action(:only => [:list, :feed, :comments_feed]) { |c| c.check_database_readable(true) }
   around_action :api_call_handle_error, :except => [:list, :feed, :comments_feed]
+  around_action :api_call_timeout, :except => [:list, :feed, :comments_feed, :upload]
   around_action :web_timeout, :only => [:list, :feed, :comments_feed]
 
   # Helper methods for checking consistency
@@ -95,8 +96,10 @@ class ChangesetController < ApplicationController
     lat << cs.max_lat unless cs.max_lat.nil?
 
     # collapse the arrays to minimum and maximum
-    cs.min_lon, cs.min_lat, cs.max_lon, cs.max_lat =
-      lon.min, lat.min, lon.max, lat.max
+    cs.min_lon = lon.min
+    cs.min_lat = lat.min
+    cs.max_lon = lon.max
+    cs.max_lat = lat.max
 
     # save the larger bounding box and return the changeset, which
     # will include the bigger bounding box.
@@ -159,7 +162,7 @@ class ChangesetController < ApplicationController
     # global (SVN-style) versioning were used - then that would be
     # unambiguous.
     elements.sort! do |a, b|
-      if (a.timestamp == b.timestamp)
+      if a.timestamp == b.timestamp
         a.version <=> b.version
       else
         a.timestamp <=> b.timestamp
@@ -179,7 +182,7 @@ class ChangesetController < ApplicationController
     # check these assertions.
     elements.each do |elt|
       result.root <<
-        if (elt.version == 1)
+        if elt.version == 1
           # first version, so it must be newly-created.
           created = XML::Node.new "create"
           created << elt.to_xml_node(changeset_cache, user_display_name_cache)
@@ -291,7 +294,7 @@ class ChangesetController < ApplicationController
         changesets = changesets.where("changesets.id <= ?", params[:max_id])
       end
 
-      @edits = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags)
+      @edits = changesets.order("changesets.id DESC").limit(20).preload(:user, :changeset_tags, :comments)
 
       render :action => :list, :layout => false
     end
@@ -324,7 +327,7 @@ class ChangesetController < ApplicationController
                                         :author => @user)
 
     # Notify current subscribers of the new comment
-    changeset.subscribers.each do |user|
+    changeset.subscribers.visible.each do |user|
       if @user != user
         Notifier.changeset_comment_notification(comment, user).deliver_now
       end
@@ -453,7 +456,7 @@ class ChangesetController < ApplicationController
   # restrict changesets to those enclosed by a bounding box
   # we need to return both the changesets and the bounding box
   def conditions_bbox(changesets, bbox)
-    if  bbox
+    if bbox
       bbox.check_boundaries
       bbox = bbox.to_scaled
       return changesets.where("min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?",