mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
fix(privacy): store environment coordinates at 1 decimal instead of 2
The home location of the environment module was rounded to 2 decimals, about 1 km, which places a home in a neighbourhood rather than the town the schema comment promised. The weather archive it feeds is gridded at 9 to 25 km, so the extra precision bought nothing. Every stored coordinate of the module now goes through the same 1-decimal rounding (about 11 km north-south, 7 km east-west at 50° N): the home, the travel periods, the geocoder's results, the per-day weather rows, and a restore of a file written with finer values. Migration 0361 rounds the existing users, travel periods and per-day rows; running it twice changes nothing more. The answers keep their shape, plain numbers. The API descriptions and the schema comment say 1 decimal now.
This commit is contained in:
1 parent
b8e78a78b3
commit
f2e32afb24
12 files changed
+347
-46
No files matched your search
@@ -11,7 +11,7 @@
|
||||
* the `environment` module off, every one of the six paths answers 403
|
||||
* `module.disabled` before it does anything else.
|
||||
*
|
||||
* Coordinates are rounded to ~city granularity (2 dp) on the way in, as a
|
||||
* Coordinates are rounded to 1 decimal (about 11 km) on the way in, as a
|
||||
* floor under whatever precision a client sends. That rounding is why the
|
||||
* geocode results and the stored home read back coarser than they were
|
||||
* picked.
|
||||
@@ -58,8 +58,10 @@ const geocodeQuery = geocodeQuerySchema.meta({
|
||||
|
||||
const environmentHome = z
|
||||
.object({
|
||||
lat: z.number().describe("Coarse latitude, rounded to 2 dp (~1 km)."),
|
||||
lon: z.number().describe("Coarse longitude, rounded to 2 dp."),
|
||||
lat: z
|
||||
.number()
|
||||
.describe("Coarse latitude, rounded to 1 decimal (about 11 km)."),
|
||||
lon: z.number().describe("Coarse longitude, rounded to 1 decimal."),
|
||||
label: z.string().nullable(),
|
||||
timezone: z
|
||||
.string()
|
||||
@@ -142,8 +144,8 @@ const environmentOverview = z
|
||||
|
||||
const geocodeResult = z
|
||||
.object({
|
||||
lat: z.number().describe("Coarse latitude, rounded to 2 dp."),
|
||||
lon: z.number().describe("Coarse longitude, rounded to 2 dp."),
|
||||
lat: z.number().describe("Coarse latitude, rounded to 1 decimal."),
|
||||
lon: z.number().describe("Coarse longitude, rounded to 1 decimal."),
|
||||
label: z
|
||||
.string()
|
||||
.describe(
|
||||
@@ -186,7 +188,7 @@ export const environmentPaths: NonNullable<ZodOpenApiObject["paths"]> = {
|
||||
tags: ["Environment"],
|
||||
summary: "Set the coarse home location",
|
||||
description:
|
||||
"Stores the picked city and stamps the effective-from instant. Coordinates are rounded to 2 dp server-side regardless of what was sent.\n\nRe-stamping is the part worth knowing: EVERY write moves `since` to now, including one that changes only the label. Days before the new `since` stop resolving against this home, so a correction to an existing home un-attributes the history that home used to cover.\n\nOn success a lookback fetch is enqueued so recent days populate without waiting for the nightly tick. That enqueue is best-effort — it no-ops cleanly when no worker is bound and the response is a 200 either way.\n\nBody cap 4 KiB. Module-gated.",
|
||||
"Stores the picked city and stamps the effective-from instant. Coordinates are rounded to 1 decimal (about 11 km) server-side regardless of what was sent.\n\nRe-stamping is the part worth knowing: EVERY write moves `since` to now, including one that changes only the label. Days before the new `since` stop resolving against this home, so a correction to an existing home un-attributes the history that home used to cover.\n\nOn success a lookback fetch is enqueued so recent days populate without waiting for the nightly tick. That enqueue is best-effort — it no-ops cleanly when no worker is bound and the response is a 200 either way.\n\nBody cap 4 KiB. Module-gated.",
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: { "application/json": { schema: homeLocationRequest } },
|
||||
@@ -309,7 +311,7 @@ export const environmentPaths: NonNullable<ZodOpenApiObject["paths"]> = {
|
||||
tags: ["Environment"],
|
||||
summary: "Add a travel override",
|
||||
description:
|
||||
"Declares that the account was somewhere other than home for an inclusive date range; the days it covers resolve against this location instead. Coordinates are rounded to 2 dp server-side.\n\nAdding one enqueues a refresh over exactly the declared window so its days re-resolve. Nothing checks for overlap with an existing override — two ranges covering the same day are accepted, and the worker picks between them.\n\nBody cap 4 KiB. Module-gated.",
|
||||
"Declares that the account was somewhere other than home for an inclusive date range; the days it covers resolve against this location instead. Coordinates are rounded to 1 decimal (about 11 km) server-side.\n\nAdding one enqueues a refresh over exactly the declared window so its days re-resolve. Nothing checks for overlap with an existing override — two ranges covering the same day are accepted, and the worker picks between them.\n\nBody cap 4 KiB. Module-gated.",
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: { "application/json": { schema: travelLocationRequest } },
|
||||
|
||||
Reference in new issue
Block a user