Permalink
Browse files

cleanup cl/el seeds

  • Loading branch information...
1 parent aeb6950 commit b0717c98065344cc693acccd772621b4a1797ca1 @geraldb geraldb committed Jul 8, 2012
Showing with 71 additions and 31 deletions.
  1. +21 −18 db/seeds/{cl.rb → cl/cl_2011_12.rb}
  2. +14 −11 db/seeds/{el.rb → cl/el_2011_12.rb}
  3. +34 −0 db/seeds/cl/teams.rb
  4. +2 −2 lib/tasks/load_uss_others.rake
View
39 db/seeds/cl.rb → db/seeds/cl/cl_2011_12.rb
@@ -2,28 +2,31 @@
# note: timezone for games (play_at) is *always* CET (central european time)
-puts "*** loading seed data in seeds/cl.rb"
+puts "*** loading seed data in seeds/cl/cl_2011_12.rb"
#################################
## Champions League 2011/12
## note :team3 => false CL has no 3rd place (only final game)
-cl = Event.create!( :title => 'Champions League 2012', :key => 'cl', :team3 => false, :start_at => Time.cet( '2011-10-10 17:00' ) )
-
-inter = Team.create!( :key => 'inter', :title => 'FC Internazionale Milano', :img => 'internazionale.png' )
-marseille = Team.create!( :key => 'marseille', :title => 'Olympique Marseille', :img => 'marseille.png' )
-bayern = Team.create!( :key => 'bayern', :title => 'FC Bayern München', :img => 'bayern.png' )
-basel = Team.create!( :key => 'basel', :title => 'FC Basel 1893', :img => 'basel.png' )
-
-chelsea = Team.create!( :title => 'Chelsea FC', :key => 'chelsea', :img => 'chelsea.png' )
-napoli = Team.create!( :title => 'SSC Napoli', :key => 'napoli', :img => 'napoli.png')
-madrid = Team.create!( :title => 'Real Madrid CF', :key => 'madrid', :img => 'madrid.png' )
-moskva = Team.create!( :title => 'PFC CSKA Moskva', :key => 'moskva', :img => 'moskva.png' )
-
-milan = Team.create!( :title => 'AC Milan', :key => 'milan', :img => 'milan.png' )
-benfica = Team.create!( :title => 'Benfica Lissabon', :key => 'benfica', :img => 'benfica.png' )
-barcelona = Team.create!( :title => 'FC Barcelona', :key => 'barcelona', :img => 'barcelona.png' )
-apoel = Team.create!( :title => 'APOEL Nikosia', :key => 'apoel', :img => 'apoel.png' )
+cl = Event.create!( :key => 'cl',
+ :title => 'Champions League 2011/12',
+ :team3 => false,
+ :start_at => Time.cet( '2011-10-10 17:00' ) )
+
+inter = Team.find_by_key!( 'inter' )
+marseille = Team.find_by_key!( 'marseille' )
+bayern = Team.find_by_key!( 'bayern' )
+basel = Team.find_by_key!( 'basel' )
+
+chelsea = Team.find_by_key!( 'chelsea' )
+napoli = Team.find_by_key!( 'napoli' )
+madrid = Team.find_by_key!( 'madrid' )
+moskva = Team.find_by_key!( 'moskva' )
+
+milan = Team.find_by_key!( 'milan' )
+benfica = Team.find_by_key!( 'benfica' )
+barcelona = Team.find_by_key!( 'barcelona' )
+apoel = Team.find_by_key!( 'apoel' )
cl.teams << milan
cl.teams << benfica
@@ -84,4 +87,4 @@
Game.create_knockouts_from_ary!( games_cl1, cl1 )
## todo: use new version constant for app module e.g. Wettpool::VERSION ??
-Prop.create!( :key => 'db.seeds.cl.version', :value => '1' )
+Prop.create!( :key => 'db.seeds.cl.2011/12.version', :value => '1' )
View
25 db/seeds/el.rb → db/seeds/cl/el_2011_12.rb
@@ -2,21 +2,24 @@
# note: timezone for games (play_at) is *always* CET (central european time)
-puts "*** loading seed data in seeds/el.rb"
+puts "*** loading seed data in seeds/cl/el_2011_12.rb"
#################################
## Europa League 2012
-el = Event.create!( :title => 'Europa League 2012', :key => 'el', :team3 => false, :start_at => Time.cet( '2011-10-10 17:00' ))
+el = Event.create!( :key => 'el',
+ :title => 'Europa League 2011/12',
+ :team3 => false,
+ :start_at => Time.cet( '2011-10-10 17:00' ))
-az = Team.create!( :title => 'AZ Alkmaar', :key => 'az', :img => 'az.png' )
-valencia = Team.create!( :title => 'Valencia CF', :key => 'valencia', :img => 'valencia.png' )
-schalke = Team.create!( :title => 'FC Schalke 04', :key => 'schalke', :img => 'schalke.png' )
-athletic = Team.create!( :title => 'Athletic Bilbao', :key => 'athletic', :img => 'athletic.png' )
-sporting = Team.create!( :title => 'Sporting Lisboa', :key => 'sporting', :img => 'sporting.png' )
-metalist = Team.create!( :title => 'FC Metalist Kharkiv', :key => 'metalist', :img => 'metalist.png' )
-atletico = Team.create!( :title => 'Atlético Madrid', :key => 'atletico', :img => 'atletico.png' )
-hannover = Team.create!( :title => 'Hannover 96', :key => 'hannover', :img => 'hannover.png' )
+az = Team.find_by_key!( 'az' )
+valencia = Team.find_by_key!( 'valencia' )
+schalke = Team.find_by_key!( 'schalke' )
+athletic = Team.find_by_key!( 'athletic' )
+sporting = Team.find_by_key!( 'sporting' )
+metalist = Team.find_by_key!( 'metalist' )
+atletico = Team.find_by_key!( 'atletico' )
+hannover = Team.find_by_key!( 'hannover' )
el.teams << az
el.teams << valencia
@@ -61,4 +64,4 @@
Game.create_knockouts_from_ary!( games_el1, el1 )
## todo: use new version constant for app module e.g. Wettpool::VERSION ??
-Prop.create!( :key => 'db.seeds.el.version', :value => '1' )
+Prop.create!( :key => 'db.seeds.el.2011/12.version', :value => '1' )
View
34 db/seeds/cl/teams.rb
@@ -0,0 +1,34 @@
+# encoding: utf-8
+
+puts "*** loading seed data in seeds/cl/teams.rb"
+
+teams = [
+ [ 'inter', 'FC Internazionale Milano', 'cl/internazionale.png' ],
+ [ 'marseille', 'Olympique Marseille', 'cl/marseille.png' ],
+ [ 'bayern', 'FC Bayern München', 'cl/bayern.png' ],
+ [ 'basel', 'FC Basel 1893', 'cl/basel.png' ],
+ [ 'chelsea', 'Chelsea FC', 'cl/chelsea.png' ],
+ [ 'napoli', 'SSC Napoli', 'cl/napoli.png' ],
+ [ 'madrid', 'Real Madrid CF', 'cl/madrid.png' ],
+ [ 'moskva', 'PFC CSKA Moskva', 'cl/moskva.png' ],
+ [ 'milan', 'AC Milan', 'cl/milan.png' ],
+ [ 'benfica', 'Benfica Lissabon', 'cl/benfica.png' ],
+ [ 'barcelona', 'FC Barcelona', 'cl/barcelona.png' ],
+ [ 'apoel', 'APOEL Nikosia', 'cl/apoel.png' ],
+
+ [ 'az', 'AZ Alkmaar', 'cl/az.png' ],
+ [ 'valencia', 'Valencia CF', 'cl/valencia.png' ],
+ [ 'schalke', 'FC Schalke 04', 'cl/schalke.png' ],
+ [ 'athletic', 'Athletic Bilbao', 'cl/athletic.png' ],
+ [ 'sporting', 'Sporting Lisboa', 'cl/sporting.png' ],
+ [ 'metalist', 'FC Metalist Kharkiv', 'cl/metalist.png' ],
+ [ 'atletico', 'Atlético Madrid', 'cl/atletico.png' ],
+ [ 'hannover', 'Hannover 96', 'cl/hannover.png' ]
+]
+
+Team.create_from_ary!( teams )
+
+
+## todo: use new version constant for app module e.g. Wettpool::VERSION ??
+Prop.create!( :key => 'db.seeds.cl.teams.version', :value => '1' )
+Prop.create!( :key => 'db.seeds.el.teams.version', :value => '1' )
View
4 lib/tasks/load_uss_others.rake
@@ -4,8 +4,8 @@ task :load_uss_others => [:environment] do |t|
# ['services', 'austria/austria2013', 'world/quali', 'uss/users' ].each do |seed|
# ['services', 'austria/teams', 'austria/bl_2011_12', 'austria/cup_2011_12', 'austria/bl_2012_13', 'austria/cup_2012_13', 'uss/users' ].each do |seed|
- ['services', 'euro/teams', 'euro/2012',
- 'world/quali_2012_13',
+ ['services',
+ 'cl/teams', 'cl/cl_2011_12', 'cl/el_2011_12',
'uss/users' ].each do |seed|
require "#{Rails.root}/db/seeds/#{seed}.rb"
end

0 comments on commit b0717c9

Please sign in to comment.