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

Optimisation de l'enregistrement des formations (#2019)

parent ef73a299
No related branches found
No related tags found
No related merge requests found
# Ce n'est pas un Job qui hérite de Communication::Website::BaseJob,
# il n'y a pas de besoin de lock ni de lien avec un site en particulier.
class Communication::Website::IndirectObject::ConnectAndSyncDirectSourcesJob < ApplicationJob
queue_as :mice
def perform(indirect_object)
indirect_object.connect_and_sync_direct_sources_safely
end
end
\ No newline at end of file
class Communication::Website::SetProgramsCategoriesJob < Communication::Website::BaseJob
queue_as :mice
def execute
website.set_programs_categories_safely
end
end
......@@ -2,12 +2,16 @@ module Communication::Website::WithProgramCategories
extend ActiveSupport::Concern
included do
after_save_commit :set_programs_categories!, if: -> (website) { website.has_education_programs? }
after_save_commit :set_programs_categories, if: -> (website) { website.has_education_programs? }
end
def set_programs_categories
Communication::Website::SetProgramsCategoriesJob.perform_later(id)
end
# TODO : I18n
# Actuellement, on ne crée que dans la langue par défaut du website, on ne gère pas les autres langues
def set_programs_categories!
def set_programs_categories_safely
[post_categories, agenda_categories].each do |objects|
programs_root_category = set_root_programs_categories_for!(objects)
set_programs_categories_at_level_for! objects, programs_root_category, education_programs.root.ordered
......
......@@ -60,6 +60,15 @@ module AsIndirectObject
dependencies
end
def connect_and_sync_direct_sources_safely
direct_sources.each do |direct_source|
direct_source.website.connect self, direct_source
end
websites.each do |website|
Communication::Website::IndirectObject::SyncWithGitJob.perform_later(website.id, indirect_object: self)
end
end
protected
def direct_sources_from_reference(reference)
......@@ -70,12 +79,7 @@ module AsIndirectObject
end
def connect_and_sync_direct_sources
direct_sources.each do |direct_source|
direct_source.website.connect self, direct_source
end
websites.each do |website|
Communication::Website::IndirectObject::SyncWithGitJob.perform_later(website.id, indirect_object: self)
end
Communication::Website::IndirectObject::ConnectAndSyncDirectSourcesJob.perform_later self
end
def add_direct_source_to_dependencies(direct_source, website, array: [])
......
......@@ -14,6 +14,6 @@ module Education::Program::WithWebsitesCategories
end
def set_websites_categories
websites.each { |website| website.set_programs_categories! }
websites.each { |website| website.set_programs_categories }
end
end
......@@ -12,6 +12,9 @@ GITHUB_WEBSITE_THEME_REPOSITORY:
GITHUB_WEBSITE_TEMPLATE_REPOSITORY:
GITHUB_ACCESS_TOKEN:
# bundle exec good_job start
GOOD_JOB_EXECUTION_MODE: external
KEYCDN_HOST:
LANGUAGE_TOOL_ADD_ON_TOKEN:
......@@ -26,11 +29,8 @@ MAINTENANCE: "false"
MICROLINK_API_KEY:
PEXELS_API_KEY:
OSUNY_API_AUTOUPDATE_THEME_KEY:
# Can be used when working on two incompatible branches (e.g. main & i18n)
OSUNY_DEVELOPMENT_DBNAME:
OSUNY_DEVELOPMENT_DBNAME: # Can be used when working on two incompatible branches (e.g. main & i18n)
OSUNY_STAGING_APP_NAME:
OSUNY_STAGING_PG_ADDON_ID:
OSUNY_SHOWCASE:
......@@ -38,6 +38,8 @@ OSUNY_TRANSPARENCY:
OTP_SECRET_ENCRYPTION_KEY:
PEXELS_API_KEY:
SCALEWAY_OS_ACCESS_KEY_ID:
SCALEWAY_OS_BUCKET:
SCALEWAY_OS_ENDPOINT:
......
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