mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Extract build_entries_from_rows for product import
This commit is contained in:
@@ -253,13 +253,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def build_entries
|
||||
rows.each_with_index do |row, i|
|
||||
row_data = Hash[[headers, row].transpose]
|
||||
entry = SpreadsheetEntry.new(row_data)
|
||||
entry.line_number = i + 2
|
||||
@entries.push entry
|
||||
end
|
||||
@entries
|
||||
@entries = build_entries_from_rows(rows)
|
||||
end
|
||||
|
||||
def save_all_valid
|
||||
@@ -272,5 +266,14 @@ module ProductImport
|
||||
return unless @file.path == Rails.root.join('tmp', 'product_import').to_s
|
||||
File.delete(@file)
|
||||
end
|
||||
|
||||
def build_entries_from_rows(rows)
|
||||
rows.each_with_index.inject([]) do |entries, (row, i)|
|
||||
row_data = Hash[[headers, row].transpose]
|
||||
entry = SpreadsheetEntry.new(row_data)
|
||||
entry.line_number = i + 2
|
||||
entries.push entry
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user