Skip to content

Commit 1e92182

Browse files
committed
feat: implement past seasons matcher display
1 parent 198e0ae commit 1e92182

3 files changed

Lines changed: 61 additions & 40 deletions

File tree

app/controllers/seasons_controller.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ def show
1919
leaguepedia.standings(tournament)
2020
end
2121

22-
@schedule = CacheService.fetch("schedule:#{@slug}", :schedule) do
23-
leaguepedia.schedule(tournament)
24-
end
22+
# Use DB-backed schedule (persists after first successful fetch)
23+
@schedule = db_schedule(tournament)
2524

2625
# Fallback 1: compute standings from schedule when TournamentResults is empty
2726
if @standings.blank? && @schedule.any?
@@ -39,8 +38,15 @@ def show
3938
aggregate_season_players(raw)
4039
end.first(10)
4140

42-
@matches_by_phase = @schedule
43-
.group_by { |m| m["Phase"].presence || "Fase de Grupos" }
41+
played = @schedule.select { |m| m["Winner"].present? }
42+
upcoming = @schedule.reject { |m| m["Winner"].present? }
43+
44+
# Group played matches by calendar date (newest first); upcoming at top if any
45+
sorted_dates = played.map { |m| m["DateTime_UTC"].to_s[0, 10] }.uniq.sort.reverse
46+
@matches_by_date = sorted_dates.map do |date|
47+
[ date, played.select { |m| m["DateTime_UTC"].to_s.start_with?(date) } ]
48+
end
49+
@upcoming_matches = upcoming
4450
end
4551

4652
private
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<% t1 = match["Team1"]; t2 = match["Team2"] %>
2+
<% winner = match["Winner"]; played = winner.present? %>
3+
<% t1s = match["Team1Score"].to_i; t2s = match["Team2Score"].to_i %>
4+
5+
<div style="border:1px solid <%= played ? 'rgba(200,155,60,0.15)' : 'rgba(5,150,170,0.12)' %>;background:rgba(15,24,35,0.6);padding:10px 14px;display:flex;align-items:center;gap:10px">
6+
<div style="flex:1;display:flex;align-items:center;gap:6px;min-width:0;opacity:<%= played && winner != t1 ? '0.4' : '1' %>">
7+
<%= team_logo(t1, size: 22) %>
8+
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:var(--retro-font);overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><%= team_abbr(t1) %></span>
9+
</div>
10+
11+
<div style="flex-shrink:0;text-align:center;min-width:56px">
12+
<% if played %>
13+
<div style="display:flex;align-items:center;justify-content:center;gap:4px">
14+
<span style="font-size:18px;font-weight:900;font-family:var(--retro-font);color:<%= winner == t1 ? 'var(--color-kl-win)' : 'rgba(255,255,255,0.2)' %>"><%= t1s %></span>
15+
<span style="color:rgba(255,255,255,0.15);font-size:16px">:</span>
16+
<span style="font-size:18px;font-weight:900;font-family:var(--retro-font);color:<%= winner == t2 ? 'var(--color-kl-win)' : 'rgba(255,255,255,0.2)' %>"><%= t2s %></span>
17+
</div>
18+
<div style="font-size:13px;color:var(--retro-gold-dim);font-family:var(--retro-font);letter-spacing:0.08em;margin-top:1px">Bo<%= match["BestOf"].to_i > 0 ? match["BestOf"] : 1 %></div>
19+
<% else %>
20+
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.15);font-family:var(--retro-font)">VS</span>
21+
<% end %>
22+
</div>
23+
24+
<div style="flex:1;display:flex;align-items:center;justify-content:flex-end;gap:6px;min-width:0;opacity:<%= played && winner != t2 ? '0.4' : '1' %>">
25+
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:var(--retro-font);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right"><%= team_abbr(t2) %></span>
26+
<%= team_logo(t2, size: 22) %>
27+
</div>
28+
29+
<div style="flex-shrink:0;min-width:54px;text-align:right">
30+
<span style="font-size:14px;color:rgba(255,255,255,0.25);font-family:var(--retro-font)"><%= format_datetime_brt(match["DateTime_UTC"]) %></span>
31+
</div>
32+
</div>

app/views/seasons/show.html.erb

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -121,51 +121,34 @@
121121
<% end %>
122122

123123
<!-- Match Results -->
124-
<% if @matches_by_phase.any? %>
124+
<% if @matches_by_date.any? || @upcoming_matches.any? %>
125125
<div style="margin-bottom:24px">
126126
<%= retro_panel(title: "Partidas", category: "// HISTÓRICO", footer: @season_data[:name]) do %>
127-
<% @matches_by_phase.each do |phase, matches| %>
127+
<% if @upcoming_matches.any? %>
128128
<div style="margin-bottom:20px">
129129
<div class="retro-sep" style="margin-bottom:12px">
130130
<div class="retro-sep-line"></div>
131-
<span class="retro-sep-label"><%= phase_label(phase) %></span>
131+
<span class="retro-sep-label">PRÓXIMAS</span>
132132
<div class="retro-sep-line-r"></div>
133133
</div>
134+
<div style="display:grid;gap:6px">
135+
<% @upcoming_matches.each do |match| %>
136+
<%= render partial: "seasons/match_row", locals: { match: match } %>
137+
<% end %>
138+
</div>
139+
</div>
140+
<% end %>
134141

142+
<% @matches_by_date.each_with_index do |(date, matches), idx| %>
143+
<div style="margin-bottom:<%= idx < @matches_by_date.length - 1 ? '20px' : '0' %>">
144+
<div class="retro-sep" style="margin-bottom:12px">
145+
<div class="retro-sep-line"></div>
146+
<span class="retro-sep-label"><%= format_date_brt(date + " 00:00:00") %></span>
147+
<div class="retro-sep-line-r"></div>
148+
</div>
135149
<div style="display:grid;gap:6px">
136150
<% matches.each do |match| %>
137-
<% t1 = match["Team1"]; t2 = match["Team2"] %>
138-
<% winner = match["Winner"]; played = winner.present? %>
139-
<% t1s = match["Team1Score"].to_i; t2s = match["Team2Score"].to_i %>
140-
141-
<div style="border:1px solid <%= played ? 'rgba(200,155,60,0.15)' : 'rgba(5,150,170,0.12)' %>;background:rgba(15,24,35,0.6);padding:10px 14px;display:flex;align-items:center;gap:10px">
142-
<div style="flex:1;display:flex;align-items:center;gap:6px;min-width:0;opacity:<%= played && winner != t1 ? '0.4' : '1' %>">
143-
<%= team_logo(t1, size: 22) %>
144-
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:var(--retro-font);overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><%= team_abbr(t1) %></span>
145-
</div>
146-
147-
<div style="flex-shrink:0;text-align:center;min-width:56px">
148-
<% if played %>
149-
<div style="display:flex;align-items:center;justify-content:center;gap:4px">
150-
<span style="font-size:18px;font-weight:900;font-family:var(--retro-font);color:<%= winner == t1 ? 'var(--color-kl-win)' : 'rgba(255,255,255,0.2)' %>"><%= t1s %></span>
151-
<span style="color:rgba(255,255,255,0.15);font-size:16px">:</span>
152-
<span style="font-size:18px;font-weight:900;font-family:var(--retro-font);color:<%= winner == t2 ? 'var(--color-kl-win)' : 'rgba(255,255,255,0.2)' %>"><%= t2s %></span>
153-
</div>
154-
<div style="font-size:17px;color:var(--retro-gold-dim);font-family:var(--retro-font);letter-spacing:0.08em;margin-top:1px">Bo<%= match["BestOf"].to_i > 0 ? match["BestOf"] : 1 %></div>
155-
<% else %>
156-
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.15);font-family:var(--retro-font)">VS</span>
157-
<% end %>
158-
</div>
159-
160-
<div style="flex:1;display:flex;align-items:center;justify-content:flex-end;gap:6px;min-width:0;opacity:<%= played && winner != t2 ? '0.4' : '1' %>">
161-
<span style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:var(--retro-font);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right"><%= team_abbr(t2) %></span>
162-
<%= team_logo(t2, size: 22) %>
163-
</div>
164-
165-
<div style="flex-shrink:0;min-width:54px;text-align:right">
166-
<span style="font-size:16px;color:rgba(255,255,255,0.25);font-family:var(--retro-font)"><%= format_datetime_brt(match["DateTime_UTC"]) %></span>
167-
</div>
168-
</div>
151+
<%= render partial: "seasons/match_row", locals: { match: match } %>
169152
<% end %>
170153
</div>
171154
</div>

0 commit comments

Comments
 (0)