[PR #5217] [MERGED] Live count: exact numbers, a history of it, and the launcher's count links to playhorizon.dev/stats #6142

Closed
opened 2026-11-03 06:14:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5217
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: feat/live-stats-exact


📝 Commits (1)

  • eccfe3d Live count: exact numbers, a history of it, and a link to playhorizon.dev/stats

📊 Changes

11 files changed (+699 additions, -67 deletions)

View changed files

📝 crates/horizon-telemetry-server/README.md (+5 -1)
➕ crates/horizon-telemetry-server/src/history.rs (+409 -0)
📝 crates/horizon-telemetry-server/src/lib.rs (+103 -6)
📝 crates/horizon-telemetry-server/src/live.rs (+14 -13)
📝 crates/horizon-telemetry-server/src/main.rs (+19 -1)
📝 crates/horizon-telemetry-server/src/store.rs (+3 -0)
📝 crates/horizon-telemetry-server/tests/live.rs (+86 -0)
📝 crates/horizon-telemetry/src/live.rs (+3 -38)
📝 docs/telemetry.md (+15 -3)
📝 launcher/src/home.rs (+19 -4)
📝 launcher/src/telemetry.rs (+23 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Ludovic asked (2026-10-31) for an exact player counter in the launcher and a page with the count over time and its peaks. This is the game-repo half; the page itself is a horizon-site PR (/stats).

What changes

  • Exact count. GET /v1/live serves exact playing, lan, versions and platforms; horizon_telemetry::live::round is gone. Versions past the 12 most played are still summed under other. The launcher already formats with thousands separators (thousands), so it now shows e.g. 1,243 playing now.
  • History (crates/horizon-telemetry-server/src/history.rs). Once a minute, the server writes down only the totals (playing, LAN, per platform; no session, version or address):
    • live_minute: one row a minute, kept 7 days (HORIZON_TELEMETRY_LIVE_MINUTE_DAYS);
    • live_hour: sum, sample count, peak and its minute, kept 90 days (…_LIVE_HOUR_DAYS, at least 31);
    • live_day: the same per UTC day, kept for good.
      Hour and day rows are upserted with each minute, so there is no roll-up job. A minute is recorded once (a late tick is ignored), and nothing is recorded during the first window (2 min) after a start, so a restart doesn't write a dip.
  • GET /v1/live/history?range=24h|7d|30d|all (default 24h): series of [start, average, peak] (5 min / 1 h / 3 h / 1 day points), the range's peak with its minute, the all_time peak, and the average per platform. Cached a minute (Cache-Control: public, max-age=60), same CORS origin, on the live count's per-address rate limit; 400 for another range.
  • Launcher. "N playing now" on the Play page is a link to <website from links.json>/stats (telemetry::stats_url, https only).
  • Docs: docs/telemetry.md and the server README no longer say "rounded" and document the history. The players' privacy text (PING) is unchanged.

The diff is ~700 lines, but 400 of them are history.rs and its tests, plus the HTTP tests and docs.

Checks

  • crates/horizon-telemetry-server (own workspace): cargo fmt, cargo clippy --all-targets -- -D warnings, cargo test: all pass (new: unit tests for record/roll-up/prune/peaks, HTTP tests for /v1/live/history and the recorder's warm-up).
  • cargo test -p horizon-telemetry --all-features and its clippy -D warnings: pass.
  • launcher: cargo fmt --check passes. I did not run pr_ready --quick locally: the Mac mini had 3–8 GB of disk free at the time, too little for the workspace clippy and a GPUI build, so the launcher's clippy and tests are CI's.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5217 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/live-stats-exact` --- ### 📝 Commits (1) - [`eccfe3d`](https://github.com/horizon-rust/horizon/commit/eccfe3d9b7fb6ee7dd0568d885769be3068b9ffc) Live count: exact numbers, a history of it, and a link to playhorizon.dev/stats ### 📊 Changes **11 files changed** (+699 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-telemetry-server/README.md` (+5 -1) ➕ `crates/horizon-telemetry-server/src/history.rs` (+409 -0) 📝 `crates/horizon-telemetry-server/src/lib.rs` (+103 -6) 📝 `crates/horizon-telemetry-server/src/live.rs` (+14 -13) 📝 `crates/horizon-telemetry-server/src/main.rs` (+19 -1) 📝 `crates/horizon-telemetry-server/src/store.rs` (+3 -0) 📝 `crates/horizon-telemetry-server/tests/live.rs` (+86 -0) 📝 `crates/horizon-telemetry/src/live.rs` (+3 -38) 📝 `docs/telemetry.md` (+15 -3) 📝 `launcher/src/home.rs` (+19 -4) 📝 `launcher/src/telemetry.rs` (+23 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Ludovic asked (2026-10-31) for an exact player counter in the launcher and a page with the count over time and its peaks. This is the game-repo half; the page itself is a horizon-site PR (`/stats`). ## What changes - **Exact count.** `GET /v1/live` serves exact `playing`, `lan`, `versions` and `platforms`; `horizon_telemetry::live::round` is gone. Versions past the 12 most played are still summed under `other`. The launcher already formats with thousands separators (`thousands`), so it now shows e.g. `1,243 playing now`. - **History** (`crates/horizon-telemetry-server/src/history.rs`). Once a minute, the server writes down only the totals (playing, LAN, per platform; no session, version or address): - `live_minute`: one row a minute, kept 7 days (`HORIZON_TELEMETRY_LIVE_MINUTE_DAYS`); - `live_hour`: sum, sample count, peak and its minute, kept 90 days (`…_LIVE_HOUR_DAYS`, at least 31); - `live_day`: the same per UTC day, kept for good. Hour and day rows are upserted with each minute, so there is no roll-up job. A minute is recorded once (a late tick is ignored), and nothing is recorded during the first window (2 min) after a start, so a restart doesn't write a dip. - **`GET /v1/live/history?range=24h|7d|30d|all`** (default 24h): `series` of `[start, average, peak]` (5 min / 1 h / 3 h / 1 day points), the range's `peak` with its minute, the `all_time` peak, and the average per platform. Cached a minute (`Cache-Control: public, max-age=60`), same CORS origin, on the live count's per-address rate limit; 400 for another range. - **Launcher.** "N playing now" on the Play page is a link to `<website from links.json>/stats` (`telemetry::stats_url`, https only). - Docs: `docs/telemetry.md` and the server README no longer say "rounded" and document the history. The players' privacy text (`PING`) is unchanged. The diff is ~700 lines, but 400 of them are `history.rs` and its tests, plus the HTTP tests and docs. ## Checks - `crates/horizon-telemetry-server` (own workspace): `cargo fmt`, `cargo clippy --all-targets -- -D warnings`, `cargo test`: all pass (new: unit tests for record/roll-up/prune/peaks, HTTP tests for `/v1/live/history` and the recorder's warm-up). - `cargo test -p horizon-telemetry --all-features` and its clippy `-D warnings`: pass. - `launcher`: `cargo fmt --check` passes. I did not run `pr_ready --quick` locally: the Mac mini had 3–8 GB of disk free at the time, too little for the workspace clippy and a GPUI build, so the launcher's clippy and tests are CI's. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:14:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6142
No description provided.