compute once dossiers count for each procedure
This commit is contained in:
parent
9bab4f9d76
commit
61d14c2c52
1 changed files with 20 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: update_procedure_dossiers_count'
|
||||
task update_procedure_dossiers_count: :environment do
|
||||
puts "Running deploy task 'update_procedure_dossiers_count'"
|
||||
progress = ProgressReport.new(Procedure.count)
|
||||
|
||||
Procedure.find_each do |p|
|
||||
progress.inc
|
||||
begin
|
||||
p.update_columns(estimated_dossiers_count: p.dossiers.visible_by_administration.count, dossiers_count_computed_at: Time.zone.now)
|
||||
rescue => e
|
||||
Sentry.capture_exception(e, extra: { procedure_id: p.id })
|
||||
end
|
||||
end
|
||||
progress.finish
|
||||
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue