Class: SimulatorChampionshipParticipation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SimulatorChampionshipParticipation
- Defined in:
- app/models/simulator_championship_participation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.to_foot_stats ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/models/simulator_championship_participation.rb', line 110 def self.to_foot_stats index = 0 self.all.map do |participation| [ participation.score, participation.to_foot_stats ] end.sort_by do |score, foot_stats_data| score end.reverse.map do |score, foot_stats_data| index += 1 foot_stats_data['Posicao'] = index.to_s foot_stats_data end end |
Instance Method Details
#score ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/simulator_championship_participation.rb', line 5 def score return @score if @score @points = 0 @matches_count = 0 @victories_count = 0 @draws_count = 0 @loss_count = 0 @home_victories = 0 @home_draws = 0 @home_loss = 0 @visitor_victories = 0 @visitor_draws = 0 @visitor_loss = 0 @team_goals = 0 @against_goals = 0 simulator_championship.simulator_matches.where(home_team_id: simulator_team_id).each do |match| match.timeline @matches_count += 1 @team_goals += match.home_score @against_goals += match.visitor_score if match.home_score > match.visitor_score @victories_count += 1 @home_victories += 1 @points += 3 else if match.home_score == match.visitor_score @draws_count += 1 @home_draws += 1 @points += 1 else @loss_count += 1 @home_loss += 1 end end end simulator_championship.simulator_matches.where(visitor_team_id: simulator_team_id).each do |match| match.timeline @matches_count += 1 @team_goals += match.visitor_score @against_goals += match.home_score if match.visitor_score > match.home_score @victories_count += 1 @visitor_victories += 1 @points += 3 else if match.visitor_score == match.home_score @draws_count += 1 @visitor_draws += 1 @points += 1 else @loss_count += 1 @visitor_loss += 1 end end end @score = [ @points, (@team_goals - @against_goals), @victories_count, @home_victories ] end |
#to_foot_stats ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/models/simulator_championship_participation.rb', line 86 def to_foot_stats { "@Id" => simulator_team_id.to_s, "@Nome" => simulator_team.full_name, "@Grupo" => "", "Pontos_Ganhos" => @points.to_s, "Jogos" => @matches_count.to_s, "Vitorias" => @victories_count.to_s, "Empates" => @draws_count.to_s, "Derrotas" => @loss_count.to_s, "Gols_Pro" => @team_goals.to_s, "Gols_Contra" => @against_goals.to_s, "Saldo_Gols" => (@team_goals - @against_goals).to_s, "Vitorias_Casa" => @home_victories.to_s, "Empates_Casa" => @home_draws.to_s, "Derrotas_Casa" => @home_loss.to_s, "Vitorias_Fora" => @visitor_victories.to_s, "Empate_Fora" => @visitor_draws.to_s, "Derrotas_Fora" => @visitor_loss.to_s, "Aproveitamento" => "", "Ponto_Maximo" => (@matches_count*3).to_s } end |