mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-14 17:06:46 +00:00
Created one page for all pools
This commit is contained in:
@@ -40,10 +40,10 @@ class StaticPagesController < ApplicationController
|
|||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = Tournament.find(@weight.tournament_id)
|
||||||
@matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id}
|
@matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id}
|
||||||
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
||||||
@poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1}
|
#@poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1}
|
||||||
@poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2}
|
#@poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2}
|
||||||
@poolThreeWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 3}
|
#@poolThreeWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 3}
|
||||||
@poolFourWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 4}
|
#@poolFourWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 4}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class Weight < ActiveRecord::Base
|
|||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
has_many :wrestlers, dependent: :destroy
|
has_many :wrestlers, dependent: :destroy
|
||||||
|
|
||||||
attr_accessor :pools, :bracket_size, :bracket_type
|
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds
|
||||||
|
|
||||||
def pools
|
def pools
|
||||||
@wrestlers = self.wrestlers
|
@wrestlers = self.wrestlers
|
||||||
@@ -111,4 +111,10 @@ class Weight < ActiveRecord::Base
|
|||||||
return @matches
|
return @matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poolRounds(matches)
|
||||||
|
@matchups = matches.select{|m| m.weight_id == self.id}
|
||||||
|
@poolMatches = @matchups.select{|m| m.bracket_position == nil}
|
||||||
|
return @poolMatches.sort_by{|m| m.round}.last.round
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
35
app/views/static_pages/_pool.html.erb
Normal file
35
app/views/static_pages/_pool.html.erb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<% @round = 1 %>
|
||||||
|
<% @pool = 1 %>
|
||||||
|
<% until @wrestlers.select{|w| w.generatePoolNumber == @pool}.blank? %>
|
||||||
|
<h5>Pool <%= @pool %></h5>
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<% until @matches.select{|m| m.round == @round}.blank? %>
|
||||||
|
<% if @round <= @weight.poolRounds(@matches) %>
|
||||||
|
<th>R<%= @round %></th>
|
||||||
|
<% end %>
|
||||||
|
<% @round = @round + 1 %>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @wrestlers.select{|w| w.generatePoolNumber == @pool}.each do |w| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= w.original_seed %> <%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %></td>
|
||||||
|
<% @round = 1 %>
|
||||||
|
<% until @matches.select{|m| m.round == @round}.blank? %>
|
||||||
|
<% if @round <= @weight.poolRounds(@matches) %>
|
||||||
|
<td><%= w.boutByRound(@round,@matches) %><br>Result</td>
|
||||||
|
<% end %>
|
||||||
|
<% @round = @round + 1 %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% @pool = @pool + 1 %>
|
||||||
|
<% @round = 1 %>
|
||||||
|
<% end %>
|
||||||
@@ -6,10 +6,18 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<h1><%= @weight.max %> lbs Bracket</h1>
|
<h1><%= @weight.max %> lbs Bracket</h1>
|
||||||
<% if @weight.pools == 4 %>
|
|
||||||
<%= render 'fourPool' %>
|
<%= render 'pool' %>
|
||||||
<% elsif @weight.pools == 2 %>
|
|
||||||
<%= render 'twoPool' %>
|
<% if @bracketType == "twoPoolsToFinal" %>
|
||||||
<% elsif @weight.pools == 1 %>
|
<%= render 'twoPoolFinalBracket' %>
|
||||||
<%= render 'onePool' %>
|
<% end %>
|
||||||
|
<% if @bracketType == "twoPoolsToSemi" %>
|
||||||
|
<%= render 'twoPoolSemiBracket' %>
|
||||||
|
<% end %>
|
||||||
|
<% if @bracketType == "fourPoolsToQuarter" %>
|
||||||
|
<%= render 'fourPoolQuarterBracket' %>
|
||||||
|
<% end %>
|
||||||
|
<% if @bracketType == "fourPoolsToSemi" %>
|
||||||
|
<%= render 'fourPoolSemiBracket' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
Reference in New Issue
Block a user