Add global ranking page

This commit is contained in:
devRaGonSa
2026-06-08 19:14:29 +02:00
parent 05d9939a23
commit dbfa28f8a4
13 changed files with 1441 additions and 232 deletions

View File

@@ -1,7 +1,7 @@
---
id: TASK-180-define-global-ranking-page-contract
title: Define global ranking page contract
status: pending
status: done
type: documentation
team: Analista
supporting_teams:
@@ -21,33 +21,33 @@ Define a separate, explicit global ranking page contract that is clearly distinc
## Context
Stats focuses on one player workflow (search and personal performance), while Ranking will expose public top lists. This task formalizes the Ranking contract, filters, payload shape, and UI states needed for an incremental, RCON-first implementation.
Stats focuses on one player workflow (search and personal performance), while Ranking exposes public top lists. This task formalizes the Ranking contract, filters, payload shape and UI states needed for an incremental, RCON-first implementation.
## Steps
1. Read the listed files first.
2. Draft a concise, implementation-ready contract for Ranking (purpose, data sources, filters, payload, and states).
2. Draft a concise, implementation-ready contract for Ranking.
3. Document how Ranking and Stats are separated and where they can share frontend patterns safely.
4. Define API expectations for weekly/monthly vs annual reads, including missing/ready/error behavior.
5. Keep constraints explicit (no Elo/MMR, no Comunidad Hispana #03, no public scoreboard as primary source when RCON exists).
6. Capture follow-up items and leave a clear next-task suggestion.
5. Keep constraints explicit.
6. Capture follow-up items and a clear next-task suggestion.
## Files to Read First
- AGENTS.md
- ai/repo-context.md
- ai/architecture-index.md
- docs/stats-section-functional-plan.md
- docs/annual-ranking-snapshot-runbook.md
- backend/app/rcon_historical_leaderboards.py
- backend/app/rcon_annual_rankings.py
- frontend/stats.html
- frontend/assets/js/stats.js
- `AGENTS.md`
- `ai/repo-context.md`
- `ai/architecture-index.md`
- `docs/stats-section-functional-plan.md`
- `docs/annual-ranking-snapshot-runbook.md`
- `backend/app/rcon_historical_leaderboards.py`
- `backend/app/rcon_annual_rankings.py`
- `frontend/stats.html`
- `frontend/assets/js/stats.js`
## Expected Files to Modify
- docs/global-ranking-page-plan.md
- ai/tasks/done/TASK-180-define-global-ranking-page-contract.md
- `docs/global-ranking-page-plan.md`
- `ai/tasks/done/TASK-180-define-global-ranking-page-contract.md`
## Constraints
@@ -60,20 +60,22 @@ Stats focuses on one player workflow (search and personal performance), while Ra
- No reintroduction of Comunidad Hispana #03.
- No public-scoreboard as primary source when RCON coverage is available.
## Validation
- Confirm `docs/global-ranking-page-plan.md` exists.
- Confirm no backend/frontend files were modified.
- Run `git diff --name-only` within task scope.
- Document explicitly that no automated tests apply.
## Outcome
- Documented Ranking goal and how it differs from Stats.
- Documented user flow:
- open Ranking page
- choose timeframe
- choose server
- choose metric
- view top players
- change filters without manual reload where feasible
- Documented expected API contract:
- weekly/monthly from RCON materialized leaderboard model
- annual from existing annual snapshot model
- Documented payload contract including:
- Created `docs/global-ranking-page-plan.md`.
- Documented a dedicated `Ranking` page contract separate from `Stats`.
- Defined dedicated endpoint direction as `GET /api/ranking`.
- Documented timeframe behavior:
- weekly/monthly from RCON materialized leaderboard reads
- annual from persisted annual snapshots
- Documented required payload fields:
- `ranking_position`
- `player_id`
- `player_name`
@@ -85,26 +87,25 @@ Stats focuses on one player workflow (search and personal performance), while Ra
- `kd_ratio`
- `window_start`
- `window_end`
- `snapshot_status` where applicable
- Documented UI states:
- `snapshot_status`
- Documented required UI states:
- loading
- backend offline
- no data
- annual snapshot missing
- unsupported metric
- controlled error
- Documented non-goals:
- Elo/MMR
- authentication
- private profile expansion
- advanced charts
- large database changes
- reintroducing Comunidad Hispana #03
- Explicitly preserved constraints:
- no Elo/MMR
- no Comunidad Hispana #03
- no public-scoreboard primary path while RCON exists
## Validation
Validation performed:
- Confirm `docs/global-ranking-page-plan.md` exists.
- Confirm no backend/frontend files were modified.
- Run `git diff --name-only` within task scope.
- If no automated tests apply, document that explicitly in Outcome.
- Confirmed documentation file creation.
- Kept changes out of `backend/` and `frontend/`.
- Automated tests do not apply to this documentation-only task.
Recommended next task:
- `TASK-181-add-global-ranking-backend-support`

View File

@@ -0,0 +1,110 @@
---
id: TASK-181-add-global-ranking-backend-support
title: Add global ranking backend support
status: done
type: backend
team: Backend Senior
supporting_teams:
- Arquitecto Python
- Arquitecto de Base de Datos
roadmap_item: foundation
priority: high
---
# TASK-181-add-global-ranking-backend-support - Add global ranking backend support
## Goal
Implement backend API support for the new global ranking page using existing RCON historical leaderboard logic and annual snapshot readers, without changing public Stats endpoints.
## Context
The backend now exposes a dedicated global ranking route that supports weekly, monthly and annual modes with V1 metric scope limited to `kills`.
## Files to Read First
- `AGENTS.md`
- `ai/repo-context.md`
- `ai/architecture-index.md`
- `docs/global-ranking-page-plan.md`
- `docs/stats-section-functional-plan.md`
- `docs/annual-ranking-snapshot-runbook.md`
- `backend/app/routes.py`
- `backend/app/payloads.py`
- `backend/app/rcon_historical_leaderboards.py`
- `backend/app/rcon_annual_rankings.py`
- `scripts/run-stats-validation.ps1`
- `scripts/run-integration-tests.ps1`
## Expected Files to Modify
- `backend/app/routes.py`
- `backend/app/payloads.py`
- `scripts/run-stats-validation.ps1`
- `ai/tasks/done/TASK-181-add-global-ranking-backend-support.md`
## Constraints Verified
- No new architecture was introduced.
- No migrations were added.
- Annual ranking remains snapshot-backed and is not recalculated per request.
- Stats endpoints were left compatible.
- Comunidad Hispana #03 was not exposed through the new route.
- Public scoreboard was not introduced as a primary ranking source.
## Outcome
- Added `GET /api/ranking`.
- Added route validation for:
- `timeframe`
- `metric`
- `limit`
- `server_id`
- required `year` when `timeframe=annual`
- Reused existing readers:
- weekly/monthly from materialized RCON leaderboard reads
- annual from annual snapshot storage
- Normalized the dedicated ranking response with:
- `page_kind`
- `timeframe`
- `server_id`
- `metric`
- `limit`
- `requested_limit`
- `effective_limit`
- `window_start`
- `window_end`
- `snapshot_status`
- `source`
- `items`
- Updated regression validation to cover the new route and its invalid-input cases.
## Validation
Executed:
- `powershell -ExecutionPolicy Bypass -File scripts/run-stats-validation.ps1`
- `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1`
- Direct local route checks through `resolve_get_payload(...)` for:
- weekly `metric=kills`
- monthly `metric=kills`
- annual `metric=kills`
- annual missing `year`
Observed:
- Weekly route returned `200`.
- Monthly route returned `200`.
- Annual route returned `200`.
- Annual route without `year` returned `400`.
- Unsupported metric returned `400`.
- Unsupported timeframe returned `400`.
- High invalid limit returned `400`.
Known limitation:
- Live HTTP verification against a running backend at `http://127.0.0.1:8000` was not available during validation; route-contract checks passed through local Python imports and the integration script reported that explicitly.
## Recommended Next Task
- `TASK-182-add-global-ranking-frontend-page`

View File

@@ -0,0 +1,99 @@
---
id: TASK-182-add-global-ranking-frontend-page
title: Add global ranking frontend page
status: done
type: frontend
team: Frontend Senior
supporting_teams:
- Experto en interfaz
- Disenador grafico
- Backend Senior
roadmap_item: foundation
priority: high
---
# TASK-182-add-global-ranking-frontend-page - Add global ranking frontend page
## Goal
Create a dedicated Ranking page that displays public top lists by timeframe, server, metric and limit, consuming the backend support built in TASK-181.
## Context
Ranking is now separated from Stats in both navigation and interaction model. Stats remains player-centric; Ranking is list-centric and links back to Stats only when a user wants individual lookup.
## Files to Read First
- `AGENTS.md`
- `ai/repo-context.md`
- `ai/architecture-index.md`
- `docs/global-ranking-page-plan.md`
- `frontend/index.html`
- `frontend/historico.html`
- `frontend/stats.html`
- `frontend/assets/js/stats.js`
- `frontend/assets/css/styles.css`
- `backend/app/routes.py`
- `ai/tasks/done/TASK-181-add-global-ranking-backend-support.md`
## Expected Files Modified
- `frontend/ranking.html`
- `frontend/assets/js/ranking.js`
- `frontend/assets/css/styles.css`
- `frontend/index.html`
- `ai/tasks/done/TASK-182-add-global-ranking-frontend-page.md`
## Constraints Verified
- No backend files were changed in this task.
- No new endpoints were added.
- No database changes were made.
- No Elo/MMR reactivation.
- No Comunidad Hispana #03 reintroduction.
- Stats behavior was left intact.
- Implementation stayed in vanilla HTML/CSS/JS.
## Outcome
- Added `frontend/ranking.html` as a dedicated Ranking page.
- Added `frontend/assets/js/ranking.js` to:
- check backend health
- request `/api/ranking`
- switch between weekly, monthly and annual flows
- render loading, offline, no-data, annual-missing and controlled-error states
- Extended shared styling in `frontend/assets/css/styles.css` for:
- ranking filter layout
- ranking metadata cards
- ranking table
- ranking empty state
- Added a minimal `Ranking` entry point in `frontend/index.html`.
- Kept cross-linking minimal by linking from Ranking to Stats without modifying `stats.html`.
## Validation
Executed:
- `node --check frontend/assets/js/ranking.js`
- `node --check frontend/assets/js/stats.js`
- `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1`
- Local static serving with `python -m http.server`
HTTP checks:
- `ranking.html` -> `200`
- `assets/js/ranking.js` -> `200`
- `stats.html` -> `200`
Offline-state check:
- Backend was unavailable at `http://127.0.0.1:8000`.
- A headless Edge DOM capture of `ranking.html` showed `#ranking-backend-state` rendered as `Backend no disponible`, confirming the intended offline fallback path.
Known limitation:
- Live successful ranking calls could not be verified through a running backend during this task because the backend was not available over HTTP in the environment.
## Recommended Follow-up
- Add a dedicated ranking frontend regression script so `ranking.html` state coverage is validated alongside existing historical and stats checks.

View File

@@ -1,93 +0,0 @@
---
id: TASK-181-add-global-ranking-backend-support
title: Add global ranking backend support
status: pending
type: backend
team: Backend Senior
supporting_teams:
- Arquitecto Python
- Arquitecto de Base de Datos
roadmap_item: foundation
priority: high
---
# TASK-181-add-global-ranking-backend-support - Add global ranking backend support
## Goal
Implement backend API support for the new global ranking page using existing RCON historical leaderboard logic and annual snapshot readers, without changing public Stats endpoints.
## Context
The backend should expose a dedicated global ranking endpoint that supports weekly/monthly and annual modes, with initial metric support set to `kills` and clear behavior for unsupported inputs and limits.
## Steps
1. Read the listed files first.
2. Reuse leaderboard query modules for weekly/monthly ranking reads.
3. Reuse annual snapshot reader for annual ranking reads, with no recalculation per request.
4. Add route-level validation for timeframe/metric/limit/year behavior.
5. Keep payload shapes compatible with future frontend rendering and existing frontend patterns.
6. Document any optional follow-up if additional metrics are delayed beyond V1.
## Files to Read First
- AGENTS.md
- ai/repo-context.md
- ai/architecture-index.md
- docs/global-ranking-page-plan.md
- docs/stats-section-functional-plan.md
- docs/annual-ranking-snapshot-runbook.md
- backend/app/routes.py
- backend/app/payloads.py
- backend/app/rcon_historical_leaderboards.py
- backend/app/rcon_annual_rankings.py
- scripts/run-stats-validation.ps1
- scripts/run-integration-tests.ps1
## Expected Files to Modify
- backend/app/routes.py
- backend/app/payloads.py, if required for response normalization
- backend/app/rcon_historical_leaderboards.py, only if small reusable exposure is needed
- backend/app/rcon_annual_rankings.py, only if response shape/read behavior adaptation is needed without changing core logic
- scripts/run-stats-validation.ps1 or a new script to cover global ranking
- ai/tasks/done/TASK-181-add-global-ranking-backend-support.md
## Constraints
- Do not create new architecture.
- Do not add large migrations.
- Do not recalculate annual ranking on each public request.
- Do not re-enable Elo/MMR.
- Do not reintroduce Comunidad Hispana #03.
- Do not use public scoreboard as primary source while RCON coverage exists.
- Preserve existing Stats endpoint compatibility.
- Avoid frontend changes unless strictly required for backend documentation-only validation.
- Keep changes scoped and verifiable.
## Outcome
- Endpoint created and documented.
- Final payload contract captured and aligned with Ranking page requirements.
- Source flow documented by timeframe:
- weekly/monthly from RCON materialized data
- annual from annual snapshot records
- Validation outputs and known limits recorded.
- Follow-up recommendation for next task: frontend page implementation.
## Validation
- Run `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1`.
- If endpoint-specific checks are added, run them in this task.
- Validate endpoint cases:
- weekly, `metric=kills`, `limit=20`
- monthly, `metric=kills`, `limit=20`
- annual, `metric=kills`, `limit=20`
- annual path with year if the implementation requires it
- low limit, for example `3`
- high invalid limit
- unsupported metric
- unsupported timeframe
- Run `git diff --name-only` within the scoped files.

View File

@@ -1,97 +0,0 @@
---
id: TASK-182-add-global-ranking-frontend-page
title: Add global ranking frontend page
status: pending
type: frontend
team: Frontend Senior
supporting_teams:
- Experto en interfaz
- Disenador grafico
- Backend Senior
roadmap_item: foundation
priority: high
---
# TASK-182-add-global-ranking-frontend-page - Add global ranking frontend page
## Goal
Create a dedicated Ranking page/section that displays global top lists by timeframe, server, metric, and limit, consuming the backend support built in TASK-181.
## Context
This page must be separated from Stats and focused on list-level ranking discovery (global leaders), while clearly linking to Stats for individual player lookup.
## Steps
1. Read the listed files first.
2. Add `frontend/ranking.html` with controls for timeframe, server, metric, and limit.
3. Implement `frontend/assets/js/ranking.js` to call the global ranking endpoint and render rows.
4. Update shared styles in `frontend/assets/css/styles.css` as needed, preserving the project visual direction.
5. Wire ranking access from existing navigation (`frontend/index.html`) only if needed.
6. Add a minimal cross-link to Stats if useful and safe.
7. Document covered UI states and fallback behavior when backend is unavailable.
## Files to Read First
- AGENTS.md
- ai/repo-context.md
- ai/architecture-index.md
- docs/global-ranking-page-plan.md
- frontend/index.html
- frontend/historico.html
- frontend/stats.html
- frontend/assets/js/stats.js
- frontend/assets/css/styles.css
- backend/app/routes.py
- ai/tasks/done/TASK-181-add-global-ranking-backend-support.md
## Expected Files to Modify
- frontend/ranking.html
- frontend/assets/js/ranking.js
- frontend/assets/css/styles.css
- frontend/index.html, only if navigation needs update
- frontend/stats.html, only if minimal cross-link is required
- scripts/run-stats-validation.ps1 or new ranking validation script
- ai/tasks/done/TASK-182-add-global-ranking-frontend-page.md
## Constraints
- No backend modifications.
- No new endpoints.
- No database migrations.
- No Elo/MMR reactivation.
- No reintroduction of Comunidad Hispana #03.
- No frameworks; continue with vanilla HTML/CSS/JS.
- Preserve military/Vietnam/tactical/sober visual identity.
- Do not regress Stats behavior.
- Avoid duplicating complex Stats logic; reuse patterns where practical.
## Outcome
- Global ranking page created and consumable.
- Endpoint consumed and documented.
- Validation of UI states:
- loading
- backend offline
- no data
- annual snapshot missing
- unsupported metric
- controlled error
- Validation list and known limitations recorded.
- Recommended follow-up tasks (if any).
## Validation
- Run `node --check frontend/assets/js/ranking.js`.
- Run `node --check frontend/assets/js/stats.js`.
- Run `powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1`.
- Serve frontend with `python -m http.server` and verify HTTP 200 for:
- `ranking.html`
- `assets/js/ranking.js`
- `stats.html`
- If backend is available, validate ranking calls against live endpoint.
- If backend is unavailable, validate UI offline state.
- Run `git diff --name-only` and verify scoped changes.