Permalink
Browse files

add calc bonus rounds

  • Loading branch information...
1 parent 65ae335 commit a32b8c7ccdbc53b46a1089d052efa98e5c413a1e @geraldb geraldb committed Jul 4, 2012
Showing with 48 additions and 0 deletions.
  1. +39 −0 db/seeds/uss/euro_bonus2.rb
  2. +9 −0 lib/tasks/load_uss_euro.rake
@@ -0,0 +1,39 @@
+
+puts "*** loading seed data in seeds/uss/euro_bonus2.rb"
+
+behrooz = User.find_by_key!( 'behroozs' )
+
+euro = Event.find_by_key!( 'euro')
+
+poolfix = Pool.find_by_event_id_and_user_id_and_fix!( euro.id, behrooz.id, true )
+poolflex = Pool.find_by_event_id_and_user_id_and_fix!( euro.id, behrooz.id, false )
+
+rfix = BonusRound.find_by_pool_id_and_pos!( poolfix.id, 2 )
+qfix = BonusQuestion.find_by_round_id_and_pos!( rfix.id, 1 )
+
+rflex = BonusRound.find_by_pool_id_and_pos!( poolflex.id, 1 )
+qflex = BonusQuestion.find_by_round_id_and_pos!( rflex.id, 1 )
+
+esp = Team.find_by_key!( 'spain' )
+ita = Team.find_by_key!( 'italy' )
+
+
+poolfix.plays.each do |play|
+ tip = BonusTip.find_by_question_id_and_user_id!( qfix.id, play.user_id )
+
+ tip.pts = 0
+ tip.pts += 3 if play.team1_id == esp.id
+ tip.pts += 2 if play.team2_id == ita.id
+ tip.save!
+end
+
+poolflex.plays.each do |play|
+ tip = BonusTip.find_by_question_id_and_user_id!( qflex.id, play.user_id )
+
+ tip.pts = 0
+ tip.pts += 3 if play.team1_id == esp.id
+ tip.pts += 2 if play.team2_id == ita.id
+ tip.save!
+end
+
+Prop.create!( :key => 'db.seeds.uss.euro.bonus2.version', :value => '1' )
@@ -17,6 +17,15 @@ task :load_uss_euro_bonus => [:environment] do |t|
end
+desc "wettpool: calc points for uss euro bonus questions"
+task :load_uss_euro_bonus2 => [:environment] do |t|
+
+ ['uss/euro_bonus2' ].each do |seed|
+ require "#{Rails.root}/db/seeds/#{seed}.rb"
+ end
+
+end
+
desc "wettpool: load seed data for uss euro pools (tips) - part ii"

0 comments on commit a32b8c7

Please sign in to comment.