Skip to content

Commit 102e9e3

Browse files
committed
feat: add objectives and improve match details
1 parent 0dd5de6 commit 102e9e3

29 files changed

Lines changed: 819 additions & 493 deletions

app/assets/tailwind/application.css

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
}
224224

225225
.retro-panel-footer-label {
226-
font-size: 9px;
226+
font-size: 12px;
227227
color: var(--retro-gold-dim);
228228
letter-spacing: 0.15em;
229229
text-transform: uppercase;
@@ -298,7 +298,7 @@
298298
flex-shrink: 0;
299299
}
300300
.retro-sep-label {
301-
font-size: 10px;
301+
font-size: 13px;
302302
color: var(--retro-gold-dim);
303303
letter-spacing: 0.2em;
304304
text-transform: uppercase;
@@ -307,7 +307,7 @@
307307

308308
/* ── RetroBadge — rótulo de categoria ── */
309309
.retro-badge {
310-
font-size: 10px;
310+
font-size: 13px;
311311
color: var(--retro-teal);
312312
letter-spacing: 0.15em;
313313
text-transform: uppercase;
@@ -317,7 +317,7 @@
317317

318318
/* ── Título retro dourado ── */
319319
.retro-title {
320-
font-size: 15px;
320+
font-size: 18px;
321321
font-weight: bold;
322322
color: var(--retro-gold);
323323
letter-spacing: 0.04em;
@@ -327,7 +327,7 @@
327327
}
328328

329329
.retro-title-lg {
330-
font-size: 22px;
330+
font-size: 30px;
331331
font-weight: bold;
332332
color: var(--retro-gold);
333333
letter-spacing: 0.04em;
@@ -349,30 +349,30 @@
349349
background: linear-gradient(to right, var(--retro-gold), transparent);
350350
}
351351
.retro-stat-label {
352-
font-size: 9px;
352+
font-size: 12px;
353353
color: var(--retro-gold-dim);
354354
letter-spacing: 0.18em;
355355
text-transform: uppercase;
356356
font-family: var(--retro-font);
357357
margin-bottom: 4px;
358358
}
359359
.retro-stat-value {
360-
font-size: 26px;
360+
font-size: 30px;
361361
font-weight: bold;
362362
color: var(--retro-gold);
363363
line-height: 1;
364364
font-family: var(--retro-font);
365365
}
366366
.retro-stat-sub {
367-
font-size: 11px;
367+
font-size: 14px;
368368
color: rgba(255,255,255,0.4);
369369
margin-top: 5px;
370370
font-family: var(--retro-font);
371371
}
372372

373373
/* ── Table rows retro ── */
374374
.retro-table-head {
375-
font-size: 10px;
375+
font-size: 13px;
376376
color: var(--retro-gold-dim);
377377
letter-spacing: 0.12em;
378378
text-transform: uppercase;
@@ -391,7 +391,7 @@
391391

392392
/* ── Section label com // prefix ── */
393393
.retro-section-label {
394-
font-size: 10px;
394+
font-size: 13px;
395395
color: var(--retro-gold-dim);
396396
letter-spacing: 0.2em;
397397
text-transform: uppercase;
@@ -401,7 +401,7 @@
401401

402402
/* ── Status badge retro ── */
403403
.retro-status {
404-
font-size: 10px;
404+
font-size: 13px;
405405
font-weight: bold;
406406
font-family: var(--retro-font);
407407
letter-spacing: 0.12em;

app/controllers/application_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def db_games(tournament = CUP_TOURNAMENT)
4747
else
4848
data = leaguepedia.scoreboard_games(tournament)
4949
LeaguepediaSyncService.new(tournament: tournament).sync_games if data.any?
50-
data
50+
data.presence
5151
end
52-
end
52+
end || []
5353
end
5454

5555
def db_players(tournament = CUP_TOURNAMENT)
@@ -60,9 +60,9 @@ def db_players(tournament = CUP_TOURNAMENT)
6060
else
6161
data = leaguepedia.scoreboard_players(tournament)
6262
LeaguepediaSyncService.new(tournament: tournament).sync_players if data.any?
63-
data
63+
data.presence
6464
end
65-
end
65+
end || []
6666
end
6767

6868
def db_champions(tournament = CUP_TOURNAMENT)

app/javascript/controllers/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Import and register all your controllers from the importmap via controllers/**/*_controller
2-
import { application } from "./application"
2+
import { application } from "controllers/application"
33

4-
import CountdownController from "./countdown_controller"
5-
import MatchAccordionController from "./match_accordion_controller"
6-
import SortTableController from "./sort_table_controller"
7-
import DraftFilterController from "./draft_filter_controller"
8-
import TabFilterController from "./tab_filter_controller"
9-
import MobileNavController from "./mobile_nav_controller"
4+
import CountdownController from "controllers/countdown_controller"
5+
import MatchAccordionController from "controllers/match_accordion_controller"
6+
import SortTableController from "controllers/sort_table_controller"
7+
import DraftFilterController from "controllers/draft_filter_controller"
8+
import TabFilterController from "controllers/tab_filter_controller"
9+
import MobileNavController from "controllers/mobile_nav_controller"
1010

1111
application.register("countdown", CountdownController)
1212
application.register("match-accordion", MatchAccordionController)

app/models/lp_game.rb

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@ class LpGame < ApplicationRecord
44

55
def as_leaguepedia_hash
66
{
7-
"UniqueGame" => unique_game,
8-
"Tournament" => tournament,
9-
"Team1" => team1.to_s,
10-
"Team2" => team2.to_s,
11-
"Winner" => winner.to_s,
12-
"Gamelength" => gamelength.to_s,
13-
"DateTime_UTC" => datetime_utc.to_s,
14-
"Team1Picks" => team1_picks.to_s,
15-
"Team2Picks" => team2_picks.to_s,
16-
"Team1Bans" => team1_bans.to_s,
17-
"Team2Bans" => team2_bans.to_s,
18-
"Team1Kills" => team1_kills.to_s,
19-
"Team2Kills" => team2_kills.to_s,
20-
"Team1Gold" => team1_gold.to_s,
21-
"Team2Gold" => team2_gold.to_s,
22-
"Patch" => patch.to_s
7+
"UniqueGame" => unique_game,
8+
"Tournament" => tournament,
9+
"Team1" => team1.to_s,
10+
"Team2" => team2.to_s,
11+
"Winner" => winner.to_s,
12+
"Gamelength" => gamelength.to_s,
13+
"DateTime_UTC" => datetime_utc.to_s,
14+
"Team1Picks" => team1_picks.to_s,
15+
"Team2Picks" => team2_picks.to_s,
16+
"Team1Bans" => team1_bans.to_s,
17+
"Team2Bans" => team2_bans.to_s,
18+
"Team1Kills" => team1_kills.to_s,
19+
"Team2Kills" => team2_kills.to_s,
20+
"Team1Gold" => team1_gold.to_s,
21+
"Team2Gold" => team2_gold.to_s,
22+
"Patch" => patch.to_s,
23+
"Team1Towers" => team1_towers.to_s,
24+
"Team2Towers" => team2_towers.to_s,
25+
"Team1Inhibitors" => team1_inhibitors.to_s,
26+
"Team2Inhibitors" => team2_inhibitors.to_s,
27+
"Team1Dragons" => team1_dragons.to_s,
28+
"Team2Dragons" => team2_dragons.to_s,
29+
"Team1Barons" => team1_barons.to_s,
30+
"Team2Barons" => team2_barons.to_s,
31+
"Team1RiftHeralds" => team1_rift_heralds.to_s,
32+
"Team2RiftHeralds" => team2_rift_heralds.to_s,
33+
"Team1VoidGrubs" => team1_void_grubs.to_s,
34+
"Team2VoidGrubs" => team2_void_grubs.to_s,
35+
"WinType" => win_type.to_s
2336
}
2437
end
2538
end

app/services/cache_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class CacheService
33
class << self
44
def fetch(key, ttl_key = :match_details, &block)
55
expires = CACHE_TTLS.fetch(ttl_key, 30.minutes)
6-
Rails.cache.fetch("kl:#{key}", expires_in: expires, &block)
6+
Rails.cache.fetch("kl:#{key}", expires_in: expires, skip_nil: true, &block)
77
rescue => e
88
Rails.logger.error("[CacheService] Cache error for '#{key}': #{e.message}")
99
block.call

app/services/leaguepedia_service.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,34 @@ def schedule(overview_page = CUP_OVERVIEW_PAGE)
5151
raw.map { |m| resolve_match_winner(m) }
5252
end
5353

54-
# Scoreboard Games — use minimal safe fields
54+
# Scoreboard Games — split into two queries to avoid MWException
5555
def scoreboard_games(tournament = CUP_TOURNAMENT)
5656
raw = cargo_query(
5757
tables: "ScoreboardGames",
5858
fields: "UniqueGame,Tournament,Team1,Team2,Winner,Gamelength,DateTime_UTC," \
5959
"Team1Picks,Team2Picks,Team1Bans,Team2Bans," \
60-
"Team1Gold,Team2Gold,Team1Kills,Team2Kills,Patch",
60+
"Team1Gold,Team2Gold,Team1Kills,Team2Kills,Patch,WinType",
6161
where: "Tournament=\"#{tournament}\"",
6262
order_by: "DateTime_UTC ASC",
6363
limit: 500
6464
)
6565
raw.map { |g| resolve_game_winner(g) }
6666
end
6767

68+
# Objectives query — separate to avoid MWException from too many fields
69+
def scoreboard_objectives(tournament = CUP_TOURNAMENT)
70+
raw = cargo_query(
71+
tables: "ScoreboardGames",
72+
fields: "UniqueGame," \
73+
"Team1Towers,Team2Towers,Team1Inhibitors,Team2Inhibitors," \
74+
"Team1Dragons,Team2Dragons,Team1Barons,Team2Barons," \
75+
"Team1RiftHeralds,Team2RiftHeralds,Team1VoidGrubs,Team2VoidGrubs",
76+
where: "Tournament=\"#{tournament}\"",
77+
limit: 500
78+
)
79+
raw.index_by { |g| g["UniqueGame"] }
80+
end
81+
6882
# Scoreboard Players
6983
def scoreboard_players(tournament = CUP_TOURNAMENT)
7084
cargo_query(

app/services/leaguepedia_sync_service.rb

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ def sync_games
4646
raw = @api.scoreboard_games(@tournament)
4747
return 0 if raw.empty?
4848

49-
existing = LpGame.where(tournament: @tournament).pluck(:unique_game).to_set
49+
# Fetch objectives in a separate query to avoid MWException
50+
objectives = {}
51+
begin
52+
sleep 1
53+
objectives = @api.scoreboard_objectives(@tournament)
54+
rescue => e
55+
Rails.logger.warn("[LeaguepediaSyncService] objectives fetch failed: #{e.message}")
56+
end
5057

5158
rows = raw.filter_map do |g|
5259
next if g["UniqueGame"].blank?
60+
obj = objectives[g["UniqueGame"]] || {}
5361
{
5462
unique_game: g["UniqueGame"],
5563
tournament: @tournament,
@@ -62,13 +70,26 @@ def sync_games
6270
team2_picks: g["Team2Picks"].to_s,
6371
team1_bans: g["Team1Bans"].to_s,
6472
team2_bans: g["Team2Bans"].to_s,
65-
team1_kills: g["Team1Kills"].to_i,
66-
team2_kills: g["Team2Kills"].to_i,
67-
team1_gold: g["Team1Gold"].to_i,
68-
team2_gold: g["Team2Gold"].to_i,
69-
patch: g["Patch"].to_s,
70-
created_at: Time.current,
71-
updated_at: Time.current
73+
team1_kills: g["Team1Kills"].to_i,
74+
team2_kills: g["Team2Kills"].to_i,
75+
team1_gold: g["Team1Gold"].to_i,
76+
team2_gold: g["Team2Gold"].to_i,
77+
patch: g["Patch"].to_s,
78+
win_type: g["WinType"].to_s,
79+
team1_towers: obj["Team1Towers"].presence&.to_i,
80+
team2_towers: obj["Team2Towers"].presence&.to_i,
81+
team1_inhibitors: obj["Team1Inhibitors"].presence&.to_i,
82+
team2_inhibitors: obj["Team2Inhibitors"].presence&.to_i,
83+
team1_dragons: obj["Team1Dragons"].presence&.to_i,
84+
team2_dragons: obj["Team2Dragons"].presence&.to_i,
85+
team1_barons: obj["Team1Barons"].presence&.to_i,
86+
team2_barons: obj["Team2Barons"].presence&.to_i,
87+
team1_rift_heralds: obj["Team1RiftHeralds"].presence&.to_i,
88+
team2_rift_heralds: obj["Team2RiftHeralds"].presence&.to_i,
89+
team1_void_grubs: obj["Team1VoidGrubs"].presence&.to_i,
90+
team2_void_grubs: obj["Team2VoidGrubs"].presence&.to_i,
91+
created_at: Time.current,
92+
updated_at: Time.current
7293
}
7394
end
7495

app/views/cup/champions.html.erb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<% [["Picks","picks"],["Bans","bans"],["Win%","winpct"],["Jogos","games"]].each do |label, key| %>
99
<% active = @sort_by == key %>
1010
<%= link_to label, cup_champions_path(sort: key),
11-
style: "font-size:10px;letter-spacing:0.1em;padding:6px 12px;font-family:Verdana,sans-serif;text-transform:uppercase;text-decoration:none;border:1px solid #{active ? 'var(--retro-gold)' : 'rgba(255,255,255,0.15)'};background:#{active ? 'rgba(200,155,60,0.15)' : 'transparent'};color:#{active ? 'var(--retro-gold)' : 'rgba(255,255,255,0.45)'}" %>
11+
style: "font-size:16px;letter-spacing:0.1em;padding:6px 12px;font-family:Verdana,sans-serif;text-transform:uppercase;text-decoration:none;border:1px solid #{active ? 'var(--retro-gold)' : 'rgba(255,255,255,0.15)'};background:#{active ? 'rgba(200,155,60,0.15)' : 'transparent'};color:#{active ? 'var(--retro-gold)' : 'rgba(255,255,255,0.45)'}" %>
1212
<% end %>
1313
</div>
1414
</div>
@@ -22,16 +22,16 @@
2222
<div style="position:relative;display:inline-block;margin-bottom:6px">
2323
<%= champion_icon(champ["Champion"], size: 52, css_class: "mx-auto") %>
2424
<% if bans > 0 %>
25-
<span style="position:absolute;top:-3px;right:-3px;width:16px;height:16px;background:#ef4444;color:#fff;font-size:11px;font-weight:bold;display:flex;align-items:center;justify-content:center;font-family:Verdana,sans-serif">
25+
<span style="position:absolute;top:-3px;right:-3px;width:16px;height:16px;background:#ef4444;color:#fff;font-size:17px;font-weight:bold;display:flex;align-items:center;justify-content:center;font-family:Verdana,sans-serif">
2626
<%= bans %>
2727
</span>
2828
<% end %>
2929
</div>
30-
<p style="font-size:11px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:Verdana,sans-serif;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><%= champ["Champion"] %></p>
31-
<p style="font-size:10px;color:var(--retro-teal);font-family:Verdana,sans-serif;margin-top:2px"><%= picks %>P <%= bans %>B</p>
30+
<p style="font-size:17px;font-weight:bold;color:rgba(255,255,255,0.85);font-family:Verdana,sans-serif;overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><%= champ["Champion"] %></p>
31+
<p style="font-size:16px;color:var(--retro-teal);font-family:Verdana,sans-serif;margin-top:2px"><%= picks %>P <%= bans %>B</p>
3232
<% if picks > 0 %>
3333
<% wr = (wins.to_f / picks * 100).round %>
34-
<p style="font-size:10px;font-family:Verdana,sans-serif;color:<%= wr >= 60 ? 'var(--color-kl-win)' : (wr >= 40 ? 'rgba(255,255,255,0.5)' : 'var(--color-kl-loss)') %>">
34+
<p style="font-size:16px;font-family:Verdana,sans-serif;color:<%= wr >= 60 ? 'var(--color-kl-win)' : (wr >= 40 ? 'rgba(255,255,255,0.5)' : 'var(--color-kl-loss)') %>">
3535
<%= wr %>%
3636
</p>
3737
<% end %>
@@ -41,8 +41,8 @@
4141
<% else %>
4242
<div style="border:1px solid var(--retro-gold-dim);padding:64px 20px;text-align:center;position:relative">
4343
<div class="retro-corners"></div>
44-
<div style="font-size:12px;color:rgba(255,255,255,0.3);font-family:Verdana,sans-serif">Sem dados de campeões ainda</div>
45-
<div style="font-size:11px;color:rgba(255,255,255,0.2);font-family:Verdana,sans-serif;margin-top:6px">Os dados aparecerão após as primeiras partidas</div>
44+
<div style="font-size:17px;color:rgba(255,255,255,0.3);font-family:Verdana,sans-serif">Sem dados de campeões ainda</div>
45+
<div style="font-size:17px;color:rgba(255,255,255,0.2);font-family:Verdana,sans-serif;margin-top:6px">Os dados aparecerão após as primeiras partidas</div>
4646
</div>
4747
<% end %>
4848
</div>

0 commit comments

Comments
 (0)