2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-05-17 16:13:05 +02:00
|
|
|
module Recovery
|
|
|
|
class RevisionImporter
|
|
|
|
attr_reader :revisions
|
|
|
|
|
|
|
|
def initialize(file_path: Recovery::RevisionExporter::FILE_PATH)
|
|
|
|
# rubocop:disable Security/MarshalLoad
|
|
|
|
@revisions = Marshal.load(File.read(file_path))
|
|
|
|
# rubocop:enable Security/MarshalLoad
|
|
|
|
end
|
|
|
|
|
|
|
|
def load
|
|
|
|
@revisions.each do |revision|
|
|
|
|
ProcedureRevisionTypeDeChamp.transaction do
|
|
|
|
revision.revision_types_de_champ.each do |coordinate|
|
|
|
|
ProcedureRevisionTypeDeChamp.upsert(coordinate.attributes)
|
|
|
|
TypeDeChamp.upsert(coordinate.type_de_champ.attributes.except('type_champs'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|