Skip to content

Instantly share code, notes, and snippets.

@defong
Last active June 9, 2021 20:10
Show Gist options
  • Save defong/0f844b0741e500f42ca15e11324723bc to your computer and use it in GitHub Desktop.
Save defong/0f844b0741e500f42ca15e11324723bc to your computer and use it in GitHub Desktop.
items = Allocation.where(recruitment_cycle_id: RecruitmentCycle.current).map do |a |
{
accredited_body_code: a.accredited_body_code,
accredited_body_name: a.accredited_body.provider_name,
provider_code: a.provider_code,
provider_name: a.provider.provider_name,
confirmed_number_of_places: a.confirmed_number_of_places,
request_type: a.request_type,
number_of_places: a.number_of_places,
url: "https://qa.publish-teacher-training-courses.service.gov.uk/organisations/#{a.accredited_body_code}/2021/allocations",
}
end
CSV.open("#{Rails.configuration.database_configuration["development"]["database"]}-allocations_broken.csv", "wb") do |csv|
csv << items.first.keys
items.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