5kmrun-bg / 5kmrun-bg/fivekmrun-app
KidsRun: engagement stats on profile page
- 主要語言
- Dart
- 星號
- 8
- 分支
- 7
- 平均合併
- 2 天 8 小時
- 30 天內合併 PR
- 30
描述
## Context
Follow-up to #185 (KidsRun future events) and #186 (KidsRun results). This issue covers surfacing **engagement stats** on the profile page for users who have participated in KidsRun events — shown only if the user has Kids history, so it stays out of the way for everyone else. Mirrors XLrun #178.
## Endpoint (verified live)
`GET https://5kmrun.bg/api/kidsrun/user/` — confirmed working. Top-level keys:
```
runners, pol_txt, pol_txt2, pol_pos, min, avg, max, sum, all_times, years
```
Same shape as the XLrun user endpoint (#178), with an extra `pol_txt2`. Structure:
- `runners` — current/most-recent year's results (each carries its own `r_finish_pos`, `r_time`, `n_name`, `e_date`, `u_*` fields).
- `years[n].results` — full per-year breakdown.
- `sum.total_runs` / `all_times` — all-time Kids history.
- `min`/`avg`/`max` — aggregate time/percentile stats.
**Caveats (same as XL):**
- **No clean numeric distance field** — distance only exists as text in `n_name` ("… 2 км"). Kids are single-distance (~2 km) so "total distance" is roughly `total_runs × 2 km`, but confirm against `n_name` rather than hardcoding.
- Kids result rows use the `_k`-suffixed percentile/best-time fields (`u_age_percent_k`, `u_best_time_k`) — see #186.
## What to build
A new stat card/tile on the **profile page** (per the XL #178 decision — not home-screen run cards or the badges tile), rendered **only if the user has Kids history** (`sum.total_runs > 0` or `runners` non-empty). Metrics to surface:
- **Kids runs this year** — from the `years` entry for the current year (`.results.length`).
- **Total Kids runs all-time** — `sum.total_runs`.
- **Best (fastest) Kids finish time** — from `min` / `u_best_time_k` / `all_times`.
- **Most recent Kids run** (date + place parsed from `n_name`).
- Optional **total Kids distance** (runs × ~2 km, or parsed from `n_name`).
## Likely files touched
- A new resource/model parallel to `lib/state/user_resource.dart` (e.g. `KidsUserResource`) to fetch/parse this endpoint.
- Profile page — new conditional stat card, following existing profile stat-card patterns.
## Related
- #185 — KidsRun future events.
- #186 — KidsRun results.
- #188 — Kids runs in the user's own runs list (**shares the same `kidsrun/user/` endpoint** — coordinate the resource layer to avoid duplicate fetches).
- XLrun stats #178 (the pattern to mirror).
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。