Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Staging] cherrypick reports task update #2621

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
TheDancingClown committed Oct 4, 2023
commit 0bfed5ad1ed5a9ca453841b949d7d8e6c3a5c647
6 changes: 3 additions & 3 deletions lib/tasks/users_reports.rake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading