Account-level import configuration templates (#1946)

* Account-level import configuration templates

* Default import to family's preferred date format
This commit is contained in:
Zach Gollwitzer
2025-03-04 13:10:01 -05:00
committed by GitHub
parent 5b2fa3d707
commit 0544089710
15 changed files with 108 additions and 43 deletions

View File

@@ -18,19 +18,8 @@ class Import::Mapping < ApplicationRecord
find_by(key: key)&.mappable
end
def sync(import)
unique_values = mapping_values(import).uniq
unique_values.each do |value|
mapping = find_or_initialize_by(key: value, import: import, create_when_empty: value.present?)
mapping.save(validate: false) if mapping.new_record?
end
where(import: import).where.not(key: unique_values).destroy_all
end
def mapping_values(import)
raise NotImplementedError, "Subclass must implement mapping_values"
def mappables_by_key(import)
raise NotImplementedError, "Subclass must implement mappables_by_key"
end
end