tasks: add a task to migrate pjs of procedures in batches
This commit is contained in:
parent
0f59f0fd4a
commit
21ac60ad04
4 changed files with 65 additions and 8 deletions
|
@ -1,8 +0,0 @@
|
|||
namespace :'2019_03_13_migrate_pjs_to_champs' do
|
||||
task run: :environment do
|
||||
procedure_id = ENV['PROCEDURE_ID']
|
||||
service = PieceJustificativeToChampPieceJointeMigrationService.new
|
||||
service.ensure_correct_storage_configuration!
|
||||
service.convert_procedure_pjs_to_champ_pjs(Procedure.find(procedure_id))
|
||||
end
|
||||
end
|
28
lib/tasks/pieces_justificatives.rake
Normal file
28
lib/tasks/pieces_justificatives.rake
Normal file
|
@ -0,0 +1,28 @@
|
|||
require Rails.root.join("lib", "tasks", "task_helper")
|
||||
|
||||
namespace :pieces_justificatives do
|
||||
task migrate_procedure_to_champs: :environment do
|
||||
procedure_id = ENV['PROCEDURE_ID']
|
||||
service = PieceJustificativeToChampPieceJointeMigrationService.new
|
||||
service.ensure_correct_storage_configuration!
|
||||
service.convert_procedure_pjs_to_champ_pjs(Procedure.find(procedure_id))
|
||||
end
|
||||
|
||||
task migrate_procedures_range_to_champs: :environment do
|
||||
if ENV['RANGE_START'].nil? || ENV['RANGE_END'].nil?
|
||||
fail "RANGE_START and RANGE_END must be specified"
|
||||
end
|
||||
procedures_range = ENV['RANGE_START']..ENV['RANGE_END']
|
||||
|
||||
service = PieceJustificativeToChampPieceJointeMigrationService.new
|
||||
service.ensure_correct_storage_configuration!
|
||||
procedures_to_migrate = service.procedures_with_pjs_in_range(procedures_range)
|
||||
|
||||
procedures_to_migrate.find_each do |procedure|
|
||||
rake_puts ''
|
||||
rake_puts "Migrating procedure #{procedure.id}…"
|
||||
|
||||
service.convert_procedure_pjs_to_champ_pjs(procedure)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue