diff --git a/app/models/concerns/with_github_files.rb b/app/models/concerns/with_github_files.rb index 79caadb30eb94a7f27daeb1b55e61d938057238d..3232d8ae353e09795d52c822b4f730ea1fad1be4 100644 --- a/app/models/concerns/with_github_files.rb +++ b/app/models/concerns/with_github_files.rb @@ -63,15 +63,17 @@ module WithGithubFiles end def publish_github_files_with_descendents - list_of_websites.each do |website| - website_github = Github.with_website website + list_of_websites.each do |current_website| + website_github = Github.with_website current_website + next unless website_github.valid? target_github_files = [] github_manifest.each do |manifest_item| - github_file = github_files.where(website: website, manifest_identifier: manifest_item[:identifier]).first_or_create + github_file = github_files.where(website: current_website, manifest_identifier: manifest_item[:identifier]).first_or_create target_github_files << github_file github_file.add_to_batch(website_github) descendents.each do |descendent| - descendent_github_file = descendent.github_files.where(website: website, manifest_identifier: manifest_item[:identifier]).first_or_create + next unless descendent.list_of_websites.include? current_website + descendent_github_file = descendent.github_files.where(website: current_website, manifest_identifier: manifest_item[:identifier]).first_or_create target_github_files << descendent_github_file descendent_github_file.add_to_batch(website_github) end @@ -85,9 +87,9 @@ module WithGithubFiles end def unpublish_github_files - list_of_websites.each do |website| + list_of_websites.each do |current_website| github_manifest.each do |manifest_item| - github_files.find_by(website: website, manifest_identifier: manifest_item[:identifier])&.unpublish + github_files.find_by(website: current_website, manifest_identifier: manifest_item[:identifier])&.unpublish end end end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index f6bddcdf33a1dc63ae92d568dd01870df8e173a9..55ed4b6ad2b1268825aa6ea507b097c69c24f433 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -114,7 +114,10 @@ class Education::Program < ApplicationRecord end def update_children_paths - children.each(&:save) + children.each do |child| + child.update_column :path, child.generated_path + child.update_children_paths + end end def list_of_other_programs