Browse Source

Set case log ID offset at export (#562)

pull/619/head
baarkerlounger 3 years ago committed by baarkerlounger
parent
commit
ad12b8e4dc
  1. 3
      app/services/exports/case_log_export_service.rb
  2. 2
      spec/services/exports/case_log_export_service_spec.rb

3
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 field_name.starts_with?("details_known_") || pattern_age.match(field_name) || omitted_attrs.include?(field_name) ? true : false
end end
LOG_ID_OFFSET = 300_000_000_000
private private
def save_export_run def save_export_run
@ -71,6 +73,7 @@ module Exports
next next
else else
value = case_log.read_attribute_before_type_cast(key) value = case_log.read_attribute_before_type_cast(key)
value += LOG_ID_OFFSET if key == "id"
form << doc.create_element(key, value) form << doc.create_element(key, value)
end end
end end

2
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) } let(:case_log) { FactoryBot.create(:case_log, :completed) }
def replace_entity_ids(export_template) 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!(/\{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!(/\{managing_org_id\}/, case_log["managing_organisation_id"].to_s)
export_template.sub!(/\{created_by_id\}/, case_log["created_by_id"].to_s) export_template.sub!(/\{created_by_id\}/, case_log["created_by_id"].to_s)

Loading…
Cancel
Save