Docs: plan and summary for the average speed over 24 hours, API and data architecture notes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC7BXv32Jwj8mY5sKX8u2F
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-07 14:30:01 +03:00
1 parent b3466f9c61
commit 00eacbbca8
5 files changed
+82

No files matched your search

+3
View File
@@ -22,6 +22,7 @@ Provides aggregated trend data for the entire server. optimized for visualizatio
* **7d**: Returns 105-minute intervals (1h 45m).
* **30d**: Returns 450-minute intervals (7h 30m).
* **Zero-Filling**: Missing data periods are automatically filled with zeros to ensure graph continuity.
* **Speed (`total_rx_rate`, `total_tx_rate`)**: for `24h` it is the peak of the summed rates over a point interval (raw `usage_history`). For `7d` and `30d` the source is `stats_hourly`, which keeps only bytes, so the rate is the **average** of an hourly bucket (`bytes * 8 / 1e6 / 3600`, Mbps), summed over clients; per point the maximum of the hourly averages is returned. Short peaks are smoothed out.
#### Example Response
```json
@@ -75,6 +76,8 @@ The API automatically selects the aggregation interval based on the requested ra
*All short-term ranges (≤24h) include automatic **Zero-Filling**.*
**Speed fields.** For ranges up to 24h `bytes_received_rate_mbps` / `bytes_sent_rate_mbps` are the peak over the point interval (raw samples). The aggregate tables (`stats_5min`, `stats_15min`, `stats_hourly`, `stats_6h`, `stats_daily`) keep only bytes, so for longer ranges (and `resolution` other than `raw`) the fields are the **average speed of the bucket**: `bytes * 8 / 1e6 / bucket seconds` (300, 900, 3600, 21600, 86400). For the current incomplete bucket the duration is `min(bucket length, time since the bucket start)`, at least 1 second. The UI labels such series "RX Mbps (avg)" / "TX Mbps (avg)". If an aggregate table is missing, the API falls back to `usage_history` and returns real speeds.
#### Examples: Long-Term Aggregated Data
To explicitly request data from long-term storage tables (skipping raw data), use the `resolution` parameter or specific ranges.
@@ -51,6 +51,8 @@ To support long-term statistics without storing billions of rows, the `TimeSerie
| `stats_6h` | **6 Hours** | 00:00, 06:00, 12:00... | 180 Days |
| `stats_daily` | **1 Day** | 00:00:00 | 365 Days |
The aggregate tables hold only `bytes_received` / `bytes_sent`, no speed. For periods over 24 hours the API derives the **average speed** of a bucket from its bytes (`bytes * 8 / 1e6 / bucket seconds`; for the current incomplete bucket the time since its start is used); peaks are available only in `usage_history` (up to 24 hours).
**Logic**: Every 10s cycle, the calculated `Increment` is added to the sum of *all* relevant overlapping buckets. A single 5MB download contributes immediately to the current 5min, 15min, Hourly, 6h, and Daily counters simultaneously.
## 3. Data Retention