Commit 6cba9b85 by Ivan

fix: fix export_headers_result with get_full_key

parent 748a384d
......@@ -193,14 +193,18 @@ module TalltyImportExport
records
end
def get_full_key header
[header.with_indifferent_access[:json], header.with_indifferent_access[:key]].compact.join('.')
end
def export_headers_result(**options)
if @headers.present? && @group_key.blank?
headers_hash = @headers.to_h { |header| [header.with_indifferent_access[:key], header] }.with_indifferent_access
headers_hash = @headers.to_h { |header| [get_full_key(header), header] }.with_indifferent_access
export_headers(**options.symbolize_keys).select do |_header|
_header.with_indifferent_access[:key].to_s.in?(headers_hash.keys)
get_full_key(_header).to_s.in?(headers_hash.keys)
end.map do |_header|
_header = _header.with_indifferent_access
_header.merge(headers_hash[_header[:key]].delete_if { |_k, v| v.blank? })
_header.merge(headers_hash[get_full_key(_header)].delete_if { |_k, v| v.blank? })
end
else
@headers = export_headers(**options.symbolize_keys)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment