2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-22 09:21:35 +01:00
|
|
|
namespace :after_party do
|
|
|
|
desc 'Deployment task: migrate_revisions'
|
|
|
|
task migrate_revisions: :environment do
|
|
|
|
puts "Running deploy task 'migrate_revisions'"
|
|
|
|
|
2022-03-11 16:54:38 +01:00
|
|
|
if defined?(TmpDossiersMigrateRevisionsJob)
|
|
|
|
procedures = Procedure.with_discarded.where(draft_revision_id: nil)
|
|
|
|
progress = ProgressReport.new(procedures.count)
|
2022-02-22 09:21:35 +01:00
|
|
|
|
2022-03-11 16:54:38 +01:00
|
|
|
puts "Processing procedures"
|
|
|
|
|
|
|
|
procedures.find_each do |procedure|
|
|
|
|
RevisionsMigration.add_revisions(procedure)
|
|
|
|
progress.inc
|
|
|
|
end
|
2022-02-22 09:21:35 +01:00
|
|
|
|
2022-03-11 16:54:38 +01:00
|
|
|
progress.finish
|
|
|
|
|
|
|
|
TmpDossiersMigrateRevisionsJob.perform_later([])
|
|
|
|
else
|
|
|
|
puts "Skip deploy task."
|
|
|
|
end
|
2022-02-22 09:21:35 +01:00
|
|
|
|
|
|
|
# Update task as completed. If you remove the line below, the task will
|
|
|
|
# run with every deploy (or every time you call after_party:run).
|
|
|
|
AfterParty::TaskRecord.create version: '20200625113026'
|
|
|
|
end
|
|
|
|
end
|