Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save defong/fd48ec8f172b8be955479d6051508c26 to your computer and use it in GitHub Desktop.
Save defong/fd48ec8f172b8be955479d6051508c26 to your computer and use it in GitHub Desktop.
[DfE] 3507-financial-support-section-displaying-incorrect-information-for-provider.rb
issues = RecruitmentCycle.current.courses.with_funding_types(["apprenticeship"]).distinct
xxxx = issues.map do |c|
provider_code = c.provider.provider_code
course__findable = c.findable?
find_url = course__findable ? "https://www.find-postgraduate-teacher-training.service.gov.uk/course/#{provider_code}/#{c.course_code}" : ""
pub_url = "https://www.publish-teacher-training-courses.service.gov.uk/organisations/#{provider_code}/2020/courses/{c.course_code}"
x = {
course__id: c.id,
course__course_code: c.course_code,
training_provider_code: provider_code,
accredited_body_code: c.accredited_body_code,
course__notes: c.to_s,
course__findable: course__findable,
training_provider__notes: c.provider.to_s,
accredited_body__notes: c.accrediting_provider&.to_s,
find_url: find_url,
pub_url: pub_url
}
x
end
CSV.open("#{Rails.configuration.database_configuration["development"]["database"]}-apprenticeship.csv", "wb") do |csv|
csv << xxxx.first.keys
xxxx.each do |hash|
csv << hash.values
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment