From 88c18b3be37326cf11d76e6362d6c74df72fd49e Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 8 Sep 2023 13:59:04 +0100 Subject: [PATCH] Add application_form:update_statuses This is a Rake task which will go through each application form and ensure that it's got the latest accurate status. --- lib/tasks/application_forms.rake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tasks/application_forms.rake b/lib/tasks/application_forms.rake index e2142f060a..26448c1aab 100644 --- a/lib/tasks/application_forms.rake +++ b/lib/tasks/application_forms.rake @@ -23,4 +23,15 @@ namespace :application_forms do count = BackfillPreliminaryChecks.call(user:) puts "Updated #{count} applications." end + + desc "Update the statuses of all application forms." + task :update_statuses, %i[staff_email] => :environment do |_task, args| + user = Staff.find_by!(email: args[:staff_email]) + ApplicationForm + .order(:id) + .find_each do |application_form| + ApplicationFormStatusUpdater.call(application_form:, user:) + puts "#{application_form.reference}: #{application_form.action_required_by} - #{application_form.status}" + end + end end