From 86b7b4afce3f489d5ff70b575371fb90625da049 Mon Sep 17 00:00:00 2001 From: Helge Rausch Date: Fri, 22 Aug 2014 08:52:45 +0200 Subject: [PATCH] Rewrite seeds in SQL to prevent Solr from indexing --- app/models/achievement.rb | 10 +++++----- db/seeds.rb | 31 +++++++++++++++++++------------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/models/achievement.rb b/app/models/achievement.rb index cd5b158..3410e83 100644 --- a/app/models/achievement.rb +++ b/app/models/achievement.rb @@ -1,8 +1,8 @@ class Achievement < ActiveRecord::Base - attr_accessible :award,:short_name - has_many :user_achievements + attr_accessible :award,:short_name + has_many :user_achievements - searchable do - text :award - end + searchable do + text :award + end end diff --git a/db/seeds.rb b/db/seeds.rb index 196a68b..7471a3d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,17 +6,24 @@ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Daley', :city => cities.first) # -#User.create(:name => "bla", :email => "abc@def.com", :password => "abc", :password_confirmation => "abc", :has_sequence => true) +#User.create(:name => 'bla', :email => 'abc@def.com', :password => 'abc', :password_confirmation => 'abc', :has_sequence => true) + if Achievement.all.length == 0 - Achievement.create(:award => "Published genotyping", :short_name => "pub_gen") - Achievement.create(:award => "Published 10 Mio. SNPs", :short_name => "10_mio") - Achievement.create(:award => "Entered first phenotype", :short_name => "1phen") - Achievement.create(:award => "Entered 5 additional phenotypes", :short_name => "5phen") - Achievement.create(:award => "Entered 10 additional phenotypes", :short_name => "10phen") - Achievement.create(:award => "Entered 20 additional phenotypes", :short_name => "20phen") - Achievement.create(:award => "Entered 50 additional phenotypes", :short_name => "50phen") - Achievement.create(:award => "Entered 100 additional phenotypes", :short_name => "100phen") - Achievement.create(:award => "Created a new phenotype", :short_name => "1addphen") - Achievement.create(:award => "Created 5 new phenotypes", :short_name => "5addphen") - Achievement.create(:award => "Created 10 new phenotypes", :short_name => "10addphen") + time = Time.now.utc + # Ths is written in SQL to prevent Solr from indexing... *le sigh* + Achievement.connection.execute(<<-SQL) + INSERT INTO achievements (award, short_name, created_at, updated_at) + VALUES + ('Published genotyping', 'pub_gen', '#{time.iso8601}', '#{time.iso8601}'), + ('Published 10 Mio. SNPs', '10_mio', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered first phenotype', '1phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered 5 additional phenotypes', '5phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered 10 additional phenotypes', '10phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered 20 additional phenotypes', '20phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered 50 additional phenotypes', '50phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Entered 100 additional phenotypes', '100phen', '#{time.iso8601}', '#{time.iso8601}'), + ('Created a new phenotype', '1addphen', '#{time.iso8601}', '#{time.iso8601}'), + ('Created 5 new phenotypes', '5addphen', '#{time.iso8601}', '#{time.iso8601}'), + ('Created 10 new phenotypes', '10addphen', '#{time.iso8601}', '#{time.iso8601}') + SQL end