diff --git a/app/models/communication/website/with_connected_objects.rb b/app/models/communication/website/with_connected_objects.rb index edcd2e610ac3b61d476e40664b7cd643c32fc2ff..a6046a0d9d62a2dcac269ec27cff04237cb8200e 100644 --- a/app/models/communication/website/with_connected_objects.rb +++ b/app/models/communication/website/with_connected_objects.rb @@ -69,6 +69,20 @@ module Communication::Website::WithConnectedObjects University::Organization.where(id: ids) end + # Synchronisation optimale d'objet indirect + def sync_indirect_object_with_git(indirect_object) + return unless git_repository.valid? + indirect_object.direct_sources.each do |direct_source| + next unless direct_source.syncable? + Communication::Website::GitFile.sync self, direct_source + direct_source.recursive_dependencies(syncable_only: true).each do |object| + Communication::Website::GitFile.sync self, object + end + end + git_repository.sync! + end + handle_asynchronously :sync_indirect_object_with_git, queue: 'default' + # ensure the object "website" respond to both is_direct_object? and is_indirect_object? as website doesn't include neither as_direct_object nor as_indirect_object def is_direct_object? true diff --git a/app/models/concerns/as_indirect_object.rb b/app/models/concerns/as_indirect_object.rb index 58859b131206621c37347f3129045ebce9c180d8..460dfd8d4de948b806e895f06c75a84e53b51df5 100644 --- a/app/models/concerns/as_indirect_object.rb +++ b/app/models/concerns/as_indirect_object.rb @@ -63,7 +63,9 @@ module AsIndirectObject def connect_and_sync_direct_sources direct_sources.each do |direct_source| direct_source.website.connect self, direct_source - direct_source.sync_with_git + end + websites.each do |website| + website.sync_indirect_object_with_git self end end end \ No newline at end of file