Skip to content

Commit

Permalink
Add application_forms:hidden_from_assessment task
Browse files Browse the repository at this point in the history
This is a task which updates the the value of the hidden_from_assessment
column on applications which were already submitted and therefore
didn't get the value set on submission.
  • Loading branch information
thomasleese committed Nov 20, 2023
1 parent fcdd5a6 commit 2056f5a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/tasks/application_forms.rake
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,36 @@ namespace :application_forms do
puts "#{application_form.reference}: #{application_form.action_required_by} - #{application_form.status}"
end
end

desc "Update hidden from assessment status for all application forms."
task update_hidden_from_assessment: :environment do |_task, _args|
zimbabwe_applications =
ApplicationForm.joins(region: :country).where(countries: { code: "ZW" })

puts "Zimbabwe: #{zimbabwe_applications.count}"
zimbabwe_applications.pluck(:reference).each { |reference| puts reference }
puts

work_history_duration_applications =
ApplicationForm
.where(stage: %w[not_started pre_assessment], needs_work_history: true)
.select(&:created_under_new_regulations?)
.select do |application_form|
WorkHistoryDuration.for_application_form(
application_form,
consider_teaching_qualification: true,
).count_months < 9
end

puts "Work history duration: #{work_history_duration_applications.count}"
work_history_duration_applications
.map(&:reference)
.each { |reference| puts reference }

ApplicationForm.where(
id:
zimbabwe_applications.pluck(:id) +
work_history_duration_applications.map(&:id),
).update_all(hidden_from_assessment: true)
end
end

0 comments on commit 2056f5a

Please sign in to comment.