Skip to content

Instantly share code, notes, and snippets.

@defong
Last active October 10, 2023 14:32
Show Gist options
  • Save defong/4cdf2bdc1bb3e8c429a7a9e4121587a5 to your computer and use it in GitHub Desktop.
Save defong/4cdf2bdc1bb3e8c429a7a9e4121587a5 to your computer and use it in GitHub Desktop.
[DfE] 2292-copy-courses-to-new-providers
copier = Courses::CopyToProviderService.new(sites_copy_to_course: Sites::CopyToCourseService, enrichments_copy_to_course: Enrichments::CopyToCourseService.new, force: true)
[
["1KN", "4B5"],
["1KY", "5B3"],
["1BK", "3M1"],
["2CC", "2O2"],
["1CU", "3V2"],
].each do |source, target|
source_provider = RecruitmentCycle.current.providers.find_by(provider_code: source)
courses = source_provider.courses.where(accredited_provider_code: ["C58", "S90"])
target_provider = RecruitmentCycle.current.providers.find_by(provider_code: target)
courses.each do |course|
course.study_sites = []
new_course = copier.execute(course:, new_provider: target_provider )
new_course.enrichments.first.draft!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment