Close stats backend validation task

This commit is contained in:
devRaGonSa
2026-06-08 14:48:32 +02:00
parent 5e8dcabd16
commit 938f10fa2e

View File

@@ -0,0 +1,131 @@
---
id: TASK-171
title: Validate Stats section with backend data
status: done
type: platform
team: Frontend Senior
supporting_teams: [Backend Senior]
roadmap_item: foundation
priority: medium
---
# TASK-171 - Validate Stats section with backend real data
## Goal
Validate the Stats section end-to-end against local backend and data sources without
introducing new features.
## Context
The previous tasks already implemented player search, player profile, annual
ranking endpoint, and the Stats frontend page.
Maintain the current product identity: Spanish-speaking HLL Vietnam community,
military/Vietnam/tactical/sober visual direction and controlled repository evolution.
## Steps
1. Confirm git status before starting validation and verify pre-existing local frontend files.
2. Read required files first (AGENTS + docs + frontend/backend files for Stats).
3. Validate backend endpoints when available:
- GET /health
- GET /api/stats/players/search?q=<query>
- GET /api/stats/players/{player_id}
- GET /api/stats/rankings/annual?year=<year>&server_id=all&metric=kills&limit=20
4. Serve or open `frontend/stats.html` and validate UI states.
5. Run required checks:
- `node --check frontend/assets/js/stats.js`
- `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1` (if applicable)
6. Record validation results and keep any changes within minimal scope.
7. If a small Stats-specific bug is found, patch it.
## Files to Read First
- AGENTS.md
- ai/repo-context.md
- ai/architecture-index.md
- docs/stats-section-functional-plan.md
- frontend/stats.html
- frontend/assets/js/stats.js
- backend/app/routes.py
- backend/app/rcon_historical_player_stats.py
- backend/app/rcon_historical_leaderboards.py
- backend/app/rcon_annual_rankings.py
## Expected Files to Modify
- ai/tasks/done/TASK-171-validate-stats-section-with-backend-data.md
- (Optional) `frontend/assets/js/stats.js` or `frontend/stats.html` only for
minimal Stats-specific bug fixes.
## Constraints
- No new features.
- No visual redesign.
- Do not touch `frontend/assets/js/partida-actual.js`.
- Do not touch `frontend/assets/img/clans/bxb.png`.
- Do not reactivate Elo/MMR.
- Do not reintroduce Comunidad Hispana #03.
- Do not modify historical workers.
- Do not modify DB unless a migration follow-up is explicitly required.
## Validation
Before completing, ensure:
- backend endpoints were tested where possible.
- frontend runtime states were checked.
- `node --check frontend/assets/js/stats.js`.
- `scripts/run-integration-tests.ps1` executed when available.
- `git diff --name-only` checked if modifications were made.
## Outcome
Status: completed
### Files read
- AGENTS.md
- ai/repo-context.md
- ai/architecture-index.md
- docs/stats-section-functional-plan.md
- frontend/stats.html
- frontend/assets/js/stats.js
- backend/app/routes.py
- backend/app/rcon_historical_player_stats.py
- backend/app/rcon_historical_leaderboards.py
- backend/app/rcon_annual_rankings.py
### Endpoints probados
- `GET /health` -> 200
- `GET /api/stats/players/search?q=rambo` -> 200 (items empty)
- `GET /api/stats/players/76561198350628987?timeframe=weekly` -> 200
- `GET /api/stats/rankings/annual?year=2026&server_id=all&metric=kills&limit=20` -> 200, `snapshot_status="ready"`
- `GET /api/stats/rankings/annual?year=1990&server_id=all&metric=kills&limit=3` -> 200, ready and empty
- `GET /api/stats/rankings/annual?year=2040&server_id=all&metric=kills&limit=20` -> 200, `snapshot_status="missing"`, `items=[]`
- `GET /api/stats/rankings/annual?year=2026&metric=deaths&limit=20` -> 400 (`Invalid metric parameter`)
### Respuestas y estado visual
- Health and payload endpoints responded correctly.
- Search can return empty set with local dataset.
- Player profile endpoint returns weekly/monthly ranking payloads and allows runtime rendering.
- Annual ranking endpoint returns ready/empty and missing states as expected.
- `frontend/stats.html` and `frontend/assets/js/stats.js` were served with HTTP 200.
- `node --check frontend/assets/js/stats.js` passed.
- Browser interactive runtime error checks could not be executed in this environment.
### Validaciones ejecutadas
- `node --check frontend/assets/js/stats.js`
- `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1`
- local backend started and queried via endpoints
- local static server started and `stats.html` / `stats.js` fetched successfully
### Validaciones pendientes / limitaciones
- No se dispuso de DB con jugadores de prueba para validar search con resultados positivos y render completo en UI.
- No se hizo comprobacion interactiva de "backend no disponible" en navegador real.
### Archivos modificados
- `ai/tasks/in-progress/TASK-171-validate-stats-section-with-backend-data.md`
### Siguiente task recomendada
- Añadir smoke test de UI con navegador/headless para validar estados runtime de `stats.js` y errores de backend en integración local.