Skip to content

Commit

Permalink
Merge pull request #14721 from isimluk/speed-up-miq_event_definition-…
Browse files Browse the repository at this point in the history
…seeds

Speed up MiqEventDefinitionSet.seed
(cherry picked from commit 42e8fc0)
  • Loading branch information
Fryguy authored and simaishi committed Apr 11, 2017
1 parent b7d8963 commit 54ffffa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/miq_event_definition_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ class MiqEventDefinitionSet < ApplicationRecord
acts_as_miq_set

def self.seed
existing = all.group_by(&:name)
CSV.foreach(fixture_path, :headers => true, :skip_lines => /^#/) do |csv_row|
set = csv_row.to_hash

rec = find_by(:name => set['name'])
rec = existing[set['name']].try(:first)
if rec.nil?
_log.info("Creating [#{set['name']}]")
create!(set)
Expand Down

0 comments on commit 54ffffa

Please sign in to comment.