]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Use tile based query when creating a way from unwayed segments.
[rails.git] / app / models / way.rb
index d86d82de684058ce601c1eb81b99ee3197088be5..c65119235372875d120c28f816e27dd3beb76ac6 100644 (file)
@@ -143,11 +143,14 @@ class Way < ActiveRecord::Base
   end
 
   def save_with_history!
+    t = Time.now
+
     Way.transaction do
-      t = Time.now
       self.timestamp = t
       self.save!
+    end
 
+    WayTag.transaction do
       tags = self.tags
 
       WayTag.delete_all(['id = ?', self.id])
@@ -159,7 +162,9 @@ class Way < ActiveRecord::Base
         tag.id = self.id
         tag.save!
       end
+    end
 
+    WaySegment.transaction do
       segs = self.segs
 
       WaySegment.delete_all(['id = ?', self.id])
@@ -173,11 +178,11 @@ class Way < ActiveRecord::Base
         seg.save!
         i += 1
       end
-
-      old_way = OldWay.from_way(self)
-      old_way.timestamp = t
-      old_way.save_with_dependencies!
     end
+
+    old_way = OldWay.from_way(self)
+    old_way.timestamp = t
+    old_way.save_with_dependencies!
   end
 
   def preconditions_ok?