From 775a47054fa120961edfa37dc26fe10f3b351c52 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 5 Jun 2023 11:34:49 +0200 Subject: [PATCH] First draft --- .../website/with_connected_objects.rb | 14 ++++++++++++++ app/models/concerns/as_indirect_object.rb | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/communication/website/with_connected_objects.rb b/app/models/communication/website/with_connected_objects.rb index edcd2e610..a6046a0d9 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 58859b131..460dfd8d4 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 -- GitLab