[#2772] Allow untranslatable dossiers to be skipped

This commit is contained in:
Frederic Merizen 2018-10-10 13:07:12 +02:00
parent dfe7f2cc45
commit 840b049cdb

View file

@ -22,6 +22,10 @@ module Tasks
check_champs_consistency("#{privacy_label}destination", @expected_destination_types_de_champ, types_de_champ(@destination_procedure))
end
def can_migrate?(dossier)
true
end
def migrate_champs(dossier)
# Since were going to iterate and change the champs at the same time,
# we use to_a to make the list static and avoid nasty surprises
@ -160,11 +164,13 @@ module Tasks
def migrate_dossiers
@source_procedure.dossiers.find_each(batch_size: 100) do |d|
@champ_mapping.migrate_champs(d)
@private_champ_mapping.migrate_champs(d)
if @champ_mapping.can_migrate?(d) && @private_champ_mapping.can_migrate?(d)
@champ_mapping.migrate_champs(d)
@private_champ_mapping.migrate_champs(d)
# Use update_columns to avoid triggering build_default_champs
d.update_columns(procedure_id: @destination_procedure.id)
# Use update_columns to avoid triggering build_default_champs
d.update_columns(procedure_id: @destination_procedure.id)
end
end
end