Skip to content

Commit

Permalink
seeds: upsert the mefs
Browse files Browse the repository at this point in the history
  • Loading branch information
freesteph committed Nov 3, 2023
1 parent 50ab033 commit c585c7f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
ministry: "MINISTERE"
}.freeze

data.each do |entry|
code = entry[MAPPING[:code]]

mef = Mef.find_or_initialize_by(code:)

mefs = data.map do |entry|
attributes = MAPPING.transform_values do |value|
if value == "MINISTERE"
Mef.ministries[entry[value].downcase]
Expand All @@ -29,9 +25,11 @@
end
end

mef.update!(attributes)
attributes
end

Mef.upsert_all(mefs, unique_by: :code) # rubocop:disable Rails/SkipsModelValidations

logger.info "[seeds] done inserting MEF codes."

logger.info "[seeds] inserting daily wages..."
Expand Down

0 comments on commit c585c7f

Please sign in to comment.