Skip to content
Snippets Groups Projects
Unverified Commit d6a352b5 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge pull request #1050 from noesya/optimize-indirect

Optimisation de la synchronisation d'objet indirect
parents 4a888c2e a6e44c96
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,16 @@ module Communication::Website::WithGitRepository
@git_repository ||= Git::Repository.new self
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|
add_direct_source_to_sync(direct_source)
end
git_repository.sync!
end
handle_asynchronously :sync_indirect_object_with_git, queue: 'default'
# Supprimer tous les git_files qui ne sont pas dans les recursive_dependencies_syncable
def destroy_obsolete_git_files
website_git_files.find_each do |git_file|
......@@ -37,4 +47,15 @@ module Communication::Website::WithGitRepository
# Clean website if about was present and changed OR a language was removed
(saved_change_to_about_id? && about_id_before_last_save.present?) || language_was_removed
end
protected
def add_direct_source_to_sync(direct_source)
return 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
# On ne synchronise pas les références de l'objet direct, car on ne le modifie pas lui.
end
end
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment