[arvados] created: 2.7.0-5671-gf7434a4918

git repository hosting git at public.arvados.org
Wed Jan 3 21:43:45 UTC 2024


        at  f7434a49187a0e429b77c45fadcbaa5413434cfc (commit)


commit f7434a49187a0e429b77c45fadcbaa5413434cfc
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Wed Jan 3 16:43:16 2024 -0500

    21290: Use update_all to efficiently sync past version records
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index b4660dbd35..16e85c0dd9 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -329,17 +329,7 @@ class Collection < ArvadosModel
   end
 
   def sync_past_versions
-    updates = self.syncable_updates
-    Collection.where('current_version_uuid = ? AND uuid != ?', self.uuid_before_last_save, self.uuid_before_last_save).each do |c|
-      c.attributes = updates
-      # Use a different validation context to skip the 'past_versions_cannot_be_updated'
-      # validator, as on this case it is legal to update some fields.
-      leave_modified_by_user_alone do
-        leave_modified_at_alone do
-          c.save(context: :update_old_versions)
-        end
-      end
-    end
+    Collection.where('current_version_uuid = ? AND uuid != ?', self.uuid_before_last_save, self.uuid_before_last_save).update_all self.syncable_updates
   end
 
   def versionable_updates?(attrs)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list