Last active
September 29, 2023 09:52
-
-
Save defong/65326082c2d9e777e39253bf9d1bd237 to your computer and use it in GitHub Desktop.
[DfE] 2244-copy-over-courses-to-providers.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copies the courses for theses providers | |
providers_to_copy_to = RecruitmentCycle.current.next.providers.where(provider_code: [ | |
"21J", | |
"2HE", | |
"1MN", | |
"21P", | |
"24P", | |
"1FE", | |
]) | |
provider_to_copy_from = RecruitmentCycle.current.next.providers.find_by(provider_code: "1TZ") | |
courses = provider_to_copy_from.courses.published | |
copier = Courses::CopyToProviderService.new(sites_copy_to_course: Sites::CopyToCourseService, enrichments_copy_to_course: Enrichments::CopyToCourseService.new, force: true) | |
providers_to_copy_to.each do |new_provider| | |
new_provider.accrediting_provider_enrichments = new_provider.accrediting_provider_enrichments + provider_to_copy_from.accrediting_provider_enrichments | |
courses.each do |course| | |
course.study_sites = [] | |
new_course = copier.execute(course:, new_provider: ) | |
new_course.enrichments.first.draft! | |
end | |
new_provider.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment