mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-12 00:09:32 +00:00
trying to speed up brackets page
This commit is contained in:
@@ -39,10 +39,10 @@ class StaticPagesController < ApplicationController
|
|||||||
|
|
||||||
def brackets
|
def brackets
|
||||||
if params[:weight]
|
if params[:weight]
|
||||||
@weight = Weight.find(params[:weight])
|
@weight = Weight.find(params[:weight]).includes(:matches,:wrestlers)
|
||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = Tournament.find(@weight.tournament_id)
|
||||||
@matches = @tournament.matches.select{|m| m.weight_id == @weight.id}
|
@matches = @weight.matches
|
||||||
@wrestlers = Wrestler.where(weight_id: @weight.id).includes(:weight,:school)
|
@wrestlers = @weight.wrestlers.includes(:school)
|
||||||
if @matches.empty? or @wrestlers.empty?
|
if @matches.empty? or @wrestlers.empty?
|
||||||
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
|
redirect_to "/static_pages/noMatches?tournament=#{@tournament.id}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Match < ActiveRecord::Base
|
|||||||
|
|
||||||
def w1_name
|
def w1_name
|
||||||
if self.w1
|
if self.w1
|
||||||
Wrestler.find(self.w1).name
|
wrestler1.name
|
||||||
else
|
else
|
||||||
self.loser1_name
|
self.loser1_name
|
||||||
end
|
end
|
||||||
@@ -49,7 +49,7 @@ class Match < ActiveRecord::Base
|
|||||||
|
|
||||||
def w2_name
|
def w2_name
|
||||||
if self.w2
|
if self.w2
|
||||||
Wrestler.find(self.w2).name
|
wrestler2.name
|
||||||
else
|
else
|
||||||
self.loser2_name
|
self.loser2_name
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
<% @mats.each.map do |m| %>
|
<% @mats.each.map do |m| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= m.name %></td>
|
<td><%= m.name %></td>
|
||||||
<td><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.wrestler1.name %> vs. <%= m.unfinishedMatches.first.wrestler2.name %></td>
|
<td><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %></td>
|
||||||
<td><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.wrestler1.name %> vs. <%= m.unfinishedMatches.second.wrestler2.name %></td>
|
<td><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %></td>
|
||||||
<td><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.wrestler1.name %> vs. <%= m.unfinishedMatches.third.wrestler2.name %></td>
|
<td><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %></td>
|
||||||
<td><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.wrestler1.name %> vs. <%= m.unfinishedMatches.fourth.wrestler2.name %></td>
|
<td><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
<td>Round <%= m.round %></td>
|
<td>Round <%= m.round %></td>
|
||||||
<td><%= m.bout_number %></td>
|
<td><%= m.bout_number %></td>
|
||||||
<td><%= m.weight_max %> lbs</td>
|
<td><%= m.weight_max %> lbs</td>
|
||||||
<td><%= m.wrestler1.name %> vs. <%= m.wrestler2.name %></td>
|
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user