summaryrefslogtreecommitdiff
path: root/lib/sampling/manual.rb
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-29 16:41:35 -0400
committertkimia <tkimia@purdue.edu>2014-04-29 16:41:35 -0400
commit42d6e3b1cc05ef5172081682b53675e4827254d3 (patch)
tree240743892a6f0948774f1b89bf5bf58ed49f6416 /lib/sampling/manual.rb
parent0d6f7a3bfbf4c87510a1bcf967b618f98e149d49 (diff)
elimination works SOMETIMES... other times it just can't put down a damned winner
Diffstat (limited to 'lib/sampling/manual.rb')
-rw-r--r--lib/sampling/manual.rb28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/sampling/manual.rb b/lib/sampling/manual.rb
index 01f6835..a9f9de4 100644
--- a/lib/sampling/manual.rb
+++ b/lib/sampling/manual.rb
@@ -33,7 +33,6 @@ module Sampling
def render_user_interaction(user)
@tournament = @match.tournament_stage.tournament
@current_user = user
- @users = @match.users
@stats = @match.stats_from(self.class)
require 'erb'
@@ -43,11 +42,28 @@ module Sampling
return erb.result(binding).html_safe
end
- def handle_user_interaction(user, sampling_params)
+ def handle_user_interaction(user, params)
# => Save sampling_params as statistics
- sampling_params.select {|name, value| @match.stats_from(self.class).include? name }.each do |name, value|
- Statistic.create(name: value, user: user, match: @match)
- end
- end
+ require 'pp'
+ puts('>'*80)
+ pp @match
+ puts('>'*80)
+ if (@match.tournament_stage.tournament.hosts.include? user)
+ manual_params = params.require(:manual)
+ winner = Team.find(manual_params[:winner])
+ @match.users.each do |user|
+ puts('>'*80)
+ pp "MAKING statistics BIIIIIIIITCH"
+ puts('>'*80)
+ Statistic.create(match: @match, user: user,
+ name: "win", value: winner.users.include?(user))
+ @match.stats_from(self.class).reject{|s|s=="win"}.each do |stat|
+ Statistic.create(match: @match, user: user,
+ name: stat, value: manual_params[:statistics][user.id][stat].to_i)
+ end # stats
+ end # users
+ end # permission
+ end # def
+
end
end