Last active
September 29, 2023 16:21
-
-
Save defong/fb28323d405fa57581898f16899787c1 to your computer and use it in GitHub Desktop.
[DfE] 5782-spike-test-exporting-large-number-of-trainees-on-report-page
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
users = User.all.filter_map { |user| { email: user.email, id: user.id, provider_ids: user.provider_ids, provider_names: user.providers.pluck(:name) } if user.provider_ids.present? } | |
items = users.map do |user| | |
trainees = Trainees::Filter.call(trainees: Trainee.includes({ provider: [:courses] }, :start_academic_cycle, :end_academic_cycle).not_draft.where(provider: {id: user[:provider_ids]}), filters: { academic_year: [AcademicCycle.previous.start_year] }) | |
user.merge(count: trainees.count ) | |
end | |
CSV.open("#{Rails.configuration.database_configuration["development"]["database"]}-love-sites-for-simon.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