feat(players): add player profile and schedule views

Implement player-facing views for profile analytics and tournament scheduling.

Changes:
- Add player profile page with partnership statistics
- Add player schedule page with upcoming matches
- Update rankings page to link to player profiles
- Add partnership tracking display in profile
- Include recent games timeline in profile

Note: Schedule view shows upcoming matches and tournament participation
This commit is contained in:
2026-03-27 12:25:14 -07:00
parent e7ddd0f72f
commit 841caa50fa
4 changed files with 387 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
<h1>Player Profile: <%= player.name %></h1>
<div class="profile-header">
<div class="player-stats">
<div class="stat">
<span class="label">ELO Rating</span>
<span class="value"><%= player.current_elo %></span>
</div>
<div class="stat">
<span class="label">Total Games</span>
<span class="value"><%= recent_games.count %></span>
</div>
<div class="stat">
<span class="label">Win Rate</span>
<span class="value"><%= (recent_games.count > 0 ? (recent_games.count { |g| g[:won] }.to_f / recent_games.count * 100).round(1) : 0) %>%</span>
</div>
</div>
</div>
<hr>
<h2>Partnership Performance</h2>
<% if partnerships.any? %>
<div class="partnerships-table">
<table>
<thead>
<tr>
<th>Partner</th>
<th>Games</th>
<th>Win Rate</th>
<th>ELO Change</th>
<th>Avg/Match</th>
<th>Last Played</th>
</tr>
</thead>
<tbody>
<% partnerships.each do |p| %>
<tr>
<td><a href="/players/<%= p[:partner][:id] %>"><%= p[:partner][:name] %></a></td>
<td><%= p[:games_played] %></td>
<td>
<%= (p[:win_rate] * 100).round(1) %>%
<div class="confidence-<%= p[:games_played] >= 30 ? 'high' : p[:games_played] >= 15 ? 'medium' : 'low' %>">
<% if p[:games_played] < 15 %>
<small>(low confidence)</small>
<% end %>
</div>
</td>
<td><%= p[:total_elo_change] > 0 ? "+" : "" %><%= p[:total_elo_change] %></td>
<td><%= p[:avg_elo_change] > 0 ? "+" : "" %><%= p[:avg_elo_change] %></td>
<td><%= p[:last_played]&.strftime('%Y-%m-%d') || '-' %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<p>No partnership data available yet.</p>
<% end %>
<hr>
<h2>Recent Games</h2>
<% if recent_games.any? %>
<div class="recent-games">
<% recent_games.each do |game| %>
<div class="game <%= game[:won] ? 'won' : 'lost' %>">
<div class="game-date">
<%= game[:date]&.strftime('%Y-%m-%d %H:%M') || 'N/A' %>
</div>
<div class="game-teams">
<div class="team team-1 <%= game[:won] ? 'winner' : '' %>">
<%= game[:team_1].map { |p| p[:name] }.join(' + ') %>
</div>
<div class="game-score">
<%= game[:score] %>
</div>
<div class="team team-2 <%= !game[:won] ? 'winner' : '' %>">
<%= game[:team_2].map { |p| p[:name] }.join(' + ') %>
</div>
</div>
<div class="game-partner">
Partner: <%= game[:player_partner][:name] %>
</div>
</div>
<% end %>
</div>
<% else %>
<p>No games played yet.</p>
<% end %>
<p><a href="/rankings">Back to Rankings</a></p>