From b35fa4b6f79d13d46eab4c9ba9e631eeb20ba73b Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 23:15:31 -0400 Subject: replaced getStatistic with focused where --- app/models/match.rb | 9 ++++++++- app/views/tournaments/standings.html.erb | 4 ++-- lib/seeding/fair_ranked_seeding.rb | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 9045d67..e817b71 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -6,7 +6,14 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" def setup() - + end + + def finished? + ok = true + tournament_stage.scoring_method.stats_needed.each do |stat| + ok &= statistics.where(match: self, name: stat).nil? + end + ok end def is_match_over(match, firstPlayer) diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb index b8739de..a04e132 100644 --- a/app/views/tournaments/standings.html.erb +++ b/app/views/tournaments/standings.html.erb @@ -1,7 +1,7 @@ -<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.getStatistic(player.matches.last, player, :score) } %> +<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.where(match: player.matches.last, user: player, name: :score) } %> <% teams = tournament_stage.matches.collect { |match| match.teams.collect { |team| team.id => team.players.collect -{ |player| player.user_name => @tournament.statistics.getStatistic(player.matches.last, player, :score } } } %> +{ |player| player.user_name => @tournament.statistics.where(match: player.matches.last, user: player, name: :score } } } %> diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 6bc62ca..870ebdd 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -33,7 +33,7 @@ module Seeding end def self.previous_score(player, tournament) - score = tournament.statistics.getStatistic(player.matches.last, player, :score) + score = tournament.statistics.where(match: player.matches.last, user: player, name: :score) if score.nil? return 0 end -- cgit v1.2.3