mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
On a per-minute heart-rate stream the 7-day chart showed only the first half of the week. The range read raw rows oldest-first under a 5000-row limit, and seven days of per-minute samples are 10 080 rows, so the newest days never arrived. The chart folds every range into days anyway, so the 7-day range now asks for one row per local day like the longer ranges. The whole week arrives whatever the sampling rate, and the 7-day and 30-day ranges share one day boundary and one source pick per day. The 7-day range still draws no spread band, so its picture is unchanged. Refs #1026
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* Query string for one type's chart series (`GET /api/measurements`).
|
|
*
|
|
* Every range asks for one row per local calendar day. The 7-day range used
|
|
* to ask for raw rows oldest-first under a 5 000-row limit; a per-minute
|
|
* heart-rate stream holds 10 080 rows in seven days, so the answer stopped
|
|
* half-way through the week and the newest days were silently missing. The
|
|
* chart folds rows into days either way, so the daily answer draws the same
|
|
* points while its size depends only on the number of days.
|
|
*
|
|
* Pure so the request the chart makes can be tested against the real route.
|
|
*/
|
|
export function chartSeriesParams(
|
|
type: string,
|
|
window: { from: string; to: string },
|
|
): URLSearchParams {
|
|
const params = new URLSearchParams();
|
|
params.set("type", type);
|
|
params.set("sortBy", "measuredAt");
|
|
params.set("sortDir", "asc");
|
|
params.set("from", window.from);
|
|
params.set("to", window.to);
|
|
params.set("limit", "5000");
|
|
params.set("aggregate", "daily");
|
|
params.set("source", "rollup");
|
|
return params;
|
|
}
|