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

Added queues for mats and provided a way for tournament directors to move matches to a mat.

This commit is contained in:
2026-02-03 17:50:52 -05:00
parent a2f8c7bced
commit 2767274066
26 changed files with 1039 additions and 196 deletions

View File

@@ -28,7 +28,7 @@ json.cache! ["api_tournament", @tournament] do
json.mats @mats do |mat|
json.name mat.name
json.unfinished_matches mat.unfinished_matches do |match|
json.unfinished_matches mat.queue_matches.compact do |match|
json.bout_number match.bout_number
json.w1_name match.w1_name
json.w2_name match.w2_name

View File

@@ -0,0 +1,34 @@
<h1>Assign Mat/Queue for Match <%= @match.bout_number %></h1>
<% if @current_mat %>
<p>Current Assignment: Mat <%= @current_mat.name %><%= @current_queue_position ? " (Queue #{@current_queue_position})" : "" %></p>
<% else %>
<p>Current Assignment: Unassigned</p>
<% end %>
<%= form_with model: @match, url: update_assignment_match_path(@match), method: :patch do |f| %>
<div class="field">
<%= f.label :mat_id, "Mat" %><br>
<%= f.collection_select :mat_id, @mats, :id, :name, { include_blank: "Unassigned" } %>
</div>
<br>
<div class="field">
<%= f.label :queue_position, "Queue Position" %><br>
<%= f.select :queue_position,
options_for_select(
[
["On Mat (Queue 1)", 1],
["On Deck (Queue 2)", 2],
["In The Hole (Queue 3)", 3],
["Warm Up (Queue 4)", 4]
],
@current_queue_position
),
include_blank: "Select position"
%>
</div>
<br>
<div class="actions">
<%= f.submit "Update Assignment", class: "btn btn-success" %>
</div>
<% end %>

View File

@@ -1,6 +1,6 @@
<% @mat = mat %>
<% @match = local_assigns[:match] || mat.unfinished_matches.first %>
<% @next_match = local_assigns[:next_match] || mat.unfinished_matches.second %>
<% @match = local_assigns[:match] || mat.queue1_match %>
<% @next_match = local_assigns[:next_match] || mat.queue2_match %>
<% @show_next_bout_button = local_assigns.key?(:show_next_bout_button) ? local_assigns[:show_next_bout_button] : true %>
<% @wrestlers = [] %>

View File

@@ -3,7 +3,11 @@
"attributes": <%= @tournament.attributes.to_json %>,
"schools": <%= @tournament.schools.map(&:attributes).to_json %>,
"weights": <%= @tournament.weights.map(&:attributes).to_json %>,
"mats": <%= @tournament.mats.map(&:attributes).to_json %>,
"mats": <%= @tournament.mats.map { |mat| mat.attributes.merge(
{
"queue_bout_numbers": mat.queue_matches.map { |match| match&.bout_number }
}
) }.to_json %>,
"wrestlers": <%= @tournament.wrestlers.map { |wrestler| wrestler.attributes.merge(
{
"school": wrestler.school&.attributes,
@@ -20,4 +24,4 @@
}
) }.to_json %>
}
}
}

View File

@@ -28,6 +28,7 @@
<td><%= match.finished %></td>
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Edit Mat/Queue', edit_assignment_match_path(match), :class=>"btn btn-primary btn-sm" %>
<%= link_to 'Stat Match', "/matches/#{match.id}/stat", :class=>"btn btn-primary btn-sm" %>
</td>
</tr>
@@ -36,4 +37,4 @@
</table>
<br>
<p>Total matches without byes: <%= @matches.select{|m| m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
<p>Unfinished matches: <%= @matches.select{|m| m.finished != 1 and m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
<p>Unfinished matches: <%= @matches.select{|m| m.finished != 1 and m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>

View File

@@ -45,31 +45,31 @@
<tr>
<td><%= m.name %></td>
<td>
<% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> (<%= m.unfinished_matches.first.bracket_position %>)<br>
<%= m.unfinished_matches.first.weight_max %> lbs
<br><%= m.unfinished_matches.first.w1_bracket_name %> vs. <br>
<%= m.unfinished_matches.first.w2_bracket_name %>
<% if m.queue1_match %><strong><%=m.queue1_match.bout_number%></strong> (<%= m.queue1_match.bracket_position %>)<br>
<%= m.queue1_match.weight_max %> lbs
<br><%= m.queue1_match.w1_bracket_name %> vs. <br>
<%= m.queue1_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> (<%= m.unfinished_matches.second.bracket_position %>)<br>
<%= m.unfinished_matches.second.weight_max %> lbs
<br><%= m.unfinished_matches.second.w1_bracket_name %> vs. <br>
<%= m.unfinished_matches.second.w2_bracket_name %>
<% if m.queue2_match %><strong><%=m.queue2_match.bout_number%></strong> (<%= m.queue2_match.bracket_position %>)<br>
<%= m.queue2_match.weight_max %> lbs
<br><%= m.queue2_match.w1_bracket_name %> vs. <br>
<%= m.queue2_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> (<%= m.unfinished_matches.third.bracket_position %>)<br>
<%= m.unfinished_matches.third.weight_max %> lbs
<br><%= m.unfinished_matches.third.w1_bracket_name %> vs. <br>
<%= m.unfinished_matches.third.w2_bracket_name %>
<% if m.queue3_match %><strong><%=m.queue3_match.bout_number%></strong> (<%= m.queue3_match.bracket_position %>)<br>
<%= m.queue3_match.weight_max %> lbs
<br><%= m.queue3_match.w1_bracket_name %> vs. <br>
<%= m.queue3_match.w2_bracket_name %>
<% end %>
</td>
<td>
<% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> (<%= m.unfinished_matches.fourth.bracket_position %>)<br>
<%= m.unfinished_matches.fourth.weight_max %> lbs
<br><%= m.unfinished_matches.fourth.w1_bracket_name %> vs. <br>
<%= m.unfinished_matches.fourth.w2_bracket_name %>
<% if m.queue4_match %><strong><%=m.queue4_match.bout_number%></strong> (<%= m.queue4_match.bracket_position %>)<br>
<%= m.queue4_match.weight_max %> lbs
<br><%= m.queue4_match.w1_bracket_name %> vs. <br>
<%= m.queue4_match.w2_bracket_name %>
<% end %>
</td>
</tr>