From 0bfed5ad1ed5a9ca453841b949d7d8e6c3a5c647 Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Wed, 4 Oct 2023 16:09:21 +0100 Subject: [PATCH] Updates user reports task to take year variable The year for the user reports is hardcoded, so this switches the task to take a year variable instead of updating each year. --- lib/tasks/users_reports.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/users_reports.rake b/lib/tasks/users_reports.rake index 4d529ace7a..94211ad70e 100644 --- a/lib/tasks/users_reports.rake +++ b/lib/tasks/users_reports.rake @@ -1,15 +1,15 @@ namespace :users_reports do desc "CSV of users for sending them a survey" - task export_csv: :environment do + task :export_csv, [:year] => :environment do |task, args| output_directory = Rails.root.join('tmp').to_s CSV.open(Rails.root.join('tmp', "submitted.csv").to_s , "wb") do |submitted_csv| CSV.open(Rails.root.join('tmp', "not_submitted.csv").to_s , "wb") do |not_submitted_csv| User.includes(:form_answers).find_each do |user| - if user.form_answers.for_year(2023).submitted.any? + if user.form_answers.for_year(args[:year]).submitted.any? submitted_csv << [user.email, user.first_name, user.last_name] - elsif user.form_answers.for_year(2023).any? + elsif user.form_answers.for_year(args[:year]).any? not_submitted_csv << [user.email, user.first_name, user.last_name] end end