mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
feat(environment): resolve past days conservatively, never guessing from home
Rework the per-day location resolution so it can no longer fabricate weather for
days before the home was set. Precedence, first hit wins:
1. an explicit dated location period (a trip, or a corrected stretch of
history) covering the day;
2. DEVICE — a reserved slot for a future client-supplied coarse per-day
location (ranks between the period and home; not produced server-side yet);
3. the home location, but only for days on/after its effective-from date;
4. otherwise the day is skipped.
The home route stamps `homeSince` whenever the home is set/updated and returns
it. The overview exposes it. Backfill bounds are now optional and default to the
conservative `[homeSince .. today]` span instead of a fixed reach onto the
current home; days before `homeSince` still resolve to a skip in the worker, so
even a wider explicit start cannot back-fill weather for the pre-home past. To
reach further back a user adds an explicit location period for that range.
Add unit coverage for the precedence (including the effective-from boundary and
the skip-not-guess rule) and the default backfill range.
This commit is contained in:
1 parent
6aad4a465e
commit
c254135406
7 files changed
+209
-29
No files matched your search
@@ -48,14 +48,19 @@ export const travelLocationSchema = z
|
||||
|
||||
export type TravelLocationInput = z.infer<typeof travelLocationSchema>;
|
||||
|
||||
/** A backfill request: fetch + store the environment rows over a date range. */
|
||||
/**
|
||||
* A backfill request: fetch + store the environment rows over a date range.
|
||||
* Both bounds are optional — an omitted span defaults to the conservative
|
||||
* `[homeSince .. today]` range on the server (never a fixed reach into the past
|
||||
* onto the current home).
|
||||
*/
|
||||
export const environmentBackfillSchema = z
|
||||
.object({
|
||||
startDate: dayStringSchema,
|
||||
endDate: dayStringSchema,
|
||||
startDate: dayStringSchema.optional(),
|
||||
endDate: dayStringSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine((v) => v.startDate <= v.endDate, {
|
||||
.refine((v) => !v.startDate || !v.endDate || v.startDate <= v.endDate, {
|
||||
message: "startDate must be on or before endDate",
|
||||
path: ["endDate"],
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user