1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added all_results page to tournaments

This commit is contained in:
2025-03-11 12:32:18 -04:00
parent 91e1939e69
commit 010d9a5f6b
7 changed files with 118 additions and 4 deletions

View File

@@ -1,10 +1,10 @@
class TournamentsController < ApplicationController
before_action :set_tournament, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
before_action :set_tournament, only: [:all_results, :delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:brackets,:generate_matches,:bracket,:all_brackets]
before_action :check_access_manage, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_action :check_tournament_errors, only: [:generate_matches]
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
before_action :check_access_read, only: [:up_matches,:bracket,:all_brackets]
before_action :check_for_matches, only: [:all_results,:up_matches,:bracket,:all_brackets]
before_action :check_access_read, only: [:all_results,:up_matches,:bracket,:all_brackets]
def weigh_in_sheet
@@ -175,6 +175,12 @@ class TournamentsController < ApplicationController
end
end
def all_results
@matches = @tournament.matches.includes(:schools,:wrestlers,:weight)
@round = nil
@bracket_position = nil
end
def generate_matches
GenerateTournamentMatches.new(@tournament).generate
end

View File

@@ -232,6 +232,21 @@ class Match < ApplicationRecord
end
end
def all_results_text
if self.finished != 1
return ""
end
if self.winner_id == self.w1
winning_wrestler = self.wrestler1
losing_wrestler = self.wrestler2
end
if self.winner_id == self.w2
winning_wrestler = self.wrestler2
losing_wrestler = self.wrestler1
end
return "#{self.weight.max} lbs - #{winning_wrestler.name} (#{winning_wrestler.school.name}) #{self.win_type} #{losing_wrestler.name} (#{losing_wrestler.school.name}) #{self.score}"
end
def bracket_winner_name
if winner_name != ""
return "#{winner_name} (#{Wrestler.find(winner_id).school.abbreviation})"

View File

@@ -12,6 +12,7 @@
<ul class="dropdown-menu">
<li><strong>Results</strong></li>
<li><%= link_to "Team Scores" , "/tournaments/#{@tournament.id}/team_scores" %></li>
<li><%= link_to "All Match Results" , "/tournaments/#{@tournament.id}/all_results" %></li>
<li><strong>Brackets</strong></li>
<% @tournament.weights.sort_by{|weight| weight.max }.each do |weight| %>
<li><%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/brackets/#{weight.id}" %></li>

View File

@@ -0,0 +1,8 @@
<% @matches.select{|m| m.finished == 1 && m.w1 && m.w2}.sort_by{|m| [ m.bout_number, m.bracket_position, m.weight.max ]}.each do |match| %>
<% if @round != match.round || @bracket_position != match.bracket_position %>
<p><strong><%= match.bracket_position %> Round: <%= match.round %></strong></p>
<% end %>
<p><%= match.all_results_text %></p>
<% @round = match.round %>
<% @bracket_position = match.bracket_position %>
<% end %>