Skip to content

Commit

Permalink
Fix add_health_questions to work with programmes
Browse files Browse the repository at this point in the history
This was written back when we had just one programme per team.
  • Loading branch information
tvararu committed Sep 27, 2024
1 parent f9ef9fb commit f9eabf9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/tasks/add_health_questions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ DESC
task :add_health_questions,
%i[team_id vaccine_id replace] => :environment do |_task, args|
team = Team.find(args[:team_id])
vaccine = team.programme.vaccines.find(args[:vaccine_id])
vaccine =
team
.programmes
.flat_map(&:vaccines)
.find { |v| v.id == args[:vaccine_id].to_i }
raise "Vaccine not found for the given team" if vaccine.nil?
existing_health_questions = vaccine.health_questions.in_order
puts "Existing health questions for #{team.name}'s #{vaccine.type} vaccine #{vaccine.brand}"
if existing_health_questions.any?
Expand Down

0 comments on commit f9eabf9

Please sign in to comment.