From ad12b8e4dc615d9b795f3718b38ec435c699e047 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 10 May 2022 12:14:44 +0100 Subject: [PATCH] Set case log ID offset at export (#562) --- app/services/exports/case_log_export_service.rb | 3 +++ spec/services/exports/case_log_export_service_spec.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/exports/case_log_export_service.rb b/app/services/exports/case_log_export_service.rb index 70600b6d7..9b786d28e 100644 --- a/app/services/exports/case_log_export_service.rb +++ b/app/services/exports/case_log_export_service.rb @@ -18,6 +18,8 @@ module Exports field_name.starts_with?("details_known_") || pattern_age.match(field_name) || omitted_attrs.include?(field_name) ? true : false end + LOG_ID_OFFSET = 300_000_000_000 + private def save_export_run @@ -71,6 +73,7 @@ module Exports next else value = case_log.read_attribute_before_type_cast(key) + value += LOG_ID_OFFSET if key == "id" form << doc.create_element(key, value) end end diff --git a/spec/services/exports/case_log_export_service_spec.rb b/spec/services/exports/case_log_export_service_spec.rb index 2eb6171b0..4fb431df4 100644 --- a/spec/services/exports/case_log_export_service_spec.rb +++ b/spec/services/exports/case_log_export_service_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Exports::CaseLogExportService do let(:case_log) { FactoryBot.create(:case_log, :completed) } def replace_entity_ids(export_template) - export_template.sub!(/\{id\}/, case_log["id"].to_s) + export_template.sub!(/\{id\}/, (case_log["id"] + Exports::CaseLogExportService::LOG_ID_OFFSET).to_s) export_template.sub!(/\{owning_org_id\}/, case_log["owning_organisation_id"].to_s) export_template.sub!(/\{managing_org_id\}/, case_log["managing_organisation_id"].to_s) export_template.sub!(/\{created_by_id\}/, case_log["created_by_id"].to_s)