Skip to content

Commit

Permalink
Use uniq instead of find_each to get pass association.push duplicatin…
Browse files Browse the repository at this point in the history
…g records

Use uniq instead of find_each to get pass association.push
duplicating records. Uniq is not doing exra query, so it should be
quicker.
  • Loading branch information
Ladas committed Mar 28, 2017
1 parent 54f7100 commit 6c3b73d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/ems_refresh/save_inventory_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def store_ids_for_new_records(records, hashes, keys)
hashes_index[build_index_from_hash(keys, hash)] = hash
end

records.find_each do |record|
records.uniq.each do |record|
record_index = build_index_from_record(keys, record)
hash = hashes_index[record_index]
hash[:id] = record.id if hash
Expand Down

0 comments on commit 6c3b73d

Please sign in to comment.