4.7 KiB
TASK-252 - Fix historical leaderboard table columns and title labels
Summary
This task fixes two regressions introduced after TASK-250 in the public historical leaderboard:
- the section title could render as
undefined ... - the primary metric column header could disappear because
hydrateWeeklyLeaderboard(...)was called with the wrong argument order in some refresh paths
It also tightens the leaderboard table behavior so each top shows only the columns that match its metric.
Files Read First
frontend/historico.htmlfrontend/assets/js/historico.js
Root Cause
1. undefined in title
buildLeaderboardTitle(...) expects a valid metric config with a .title.
After TASK-250, some calls to hydrateWeeklyLeaderboard(...) still used the old function signature and omitted the new ratioHeadingNode argument. That shifted the remaining arguments:
weeklyWindowNoteNodewas received asratioHeadingNodeweeklySnapshotMetaNodewas received asnoteNode- the metric config was received as
snapshotMetaNode - the timeframe string was received as
metricConfig
That left metricConfig.title undefined and produced titles like:
undefined Semanal - Todos los servidores
2. Primary metric header missing
The same bad argument order also broke the header sync path:
- the value column header was still updated
- but the ratio-heading logic was running against the wrong node
- depending on the metric, the table could lose the intended visible structure and appear with the main metric column effectively unlabeled in production
Changes Applied
- Updated every
hydrateWeeklyLeaderboard(...)call to passweeklyRatioHeadingNodein the correct position. - Hardened
buildLeaderboardTitle(...)so it always falls back to a safe metric config and never emitsundefined. - Adjusted metric labels to match the required public wording:
kills-> titleTop kills, value headingKillsdeaths-> titleTop muertes, value headingMuertesmatches_over_100_kills-> titlePartidas 100+ kills, value headingPartidas 100+ killssupport-> titleSoporte, value headingSoporte
- Kept ratio-column behavior metric-aware:
- kills ->
Kills/partida - deaths ->
Muertes/partida - matches_over_100_kills -> no ratio column
- support ->
Soporte/partidaonly when rows exist; otherwise the ratio column stays hidden
- kills ->
Final Headers By Top
Top kills
Pos.JugadorKillsPartidasKills/partida
Top muertes
Pos.JugadorMuertesPartidasMuertes/partida
Partidas 100+ kills
Pos.JugadorPartidas 100+ killsPartidas
Soporte
If rows exist:
Pos.JugadorSoportePartidasSoporte/partida
If no rows exist:
Pos.JugadorSoportePartidas
Support Status
Current support payload behavior was reviewed only to the extent needed to diagnose the UI:
- the RCON historical leaderboard code documents support as a special case
- when support data is not available from the materialized RCON read model, it returns an empty supported payload instead of falling back to unrelated public-scoreboard totals
Frontend behavior now matches that contract:
- no
undefined - no stale
Kills/partida - no ratio column for support when there are no rows
Validation
Executed:
node --check frontend/assets/js/historico.js
Static checks:
- every
hydrateWeeklyLeaderboard(...)call now passesweeklyRatioHeadingNode buildLeaderboardTitle(...)has a safe fallback path and no longer depends on an uncheckedmetricConfig.title- header/value mappings were checked for:
killsdeathsmatches_over_100_killssupport
Expected output matrix:
- kills ->
Pos., Jugador, Kills, Partidas, Kills/partida - deaths ->
Pos., Jugador, Muertes, Partidas, Muertes/partida - matches_over_100_kills ->
Pos., Jugador, Partidas 100+ kills, Partidas - support ->
Pos., Jugador, Soporte, Partidas, plusSoporte/partidaonly when rows exist
Post-Deploy Visual Check
- Open
historico.html - Select
Semanal + Top kills- title must be
Top kills Semanal - ... Killscolumn visibleKills/partidavisible
- title must be
- Select
Mensual + Top muertes- title must be
Top muertes Mensual - ... Muertescolumn visibleMuertes/partidavisible
- title must be
- Select
Partidas 100+ kills- title must be
Partidas 100+ kills ... Partidas 100+ killscolumn visible- no ratio column
- title must be
- Select
Soporte- title must be
Soporte ... - no
undefined - no
Kills/partida - if no rows, empty state remains intact
- title must be
Notes
- No backend changes were required.
- No assets, maps, brands, clan images or weapon images were modified.