mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
iOS-operator-blocking hotfix for REG-11 — Home dashboard tile renders neither chart nor latest value for BP / Puls / Körperfett when the most recent reading is older than 7 days. Root cause was in `/api/dashboard/summary` SQL gates; `latestIn7d` + `sparkBuckets` both required `measured_at >= sevenDaysAgo`, which returned empty for sparse accounts, leaving the iOS tile with `latestValue: null` + `sparkline: []` to render from. Detail-screen (`/api/measurements/series?kind=…`) escaped because of its broader window. Server-side changes: - `latestIn7d` → `latestEver` (drops 7-day filter; DISTINCT ON returns latest reading EVER per type, bounded at N_metrics rows). - `sparkBuckets` rewritten via ROW_NUMBER() OVER (PARTITION BY type ORDER BY bucket_start DESC) so the trailing N daily buckets per type render regardless of age, bounded at SPARK_DAYS × N_metrics. - BP + Pulse metrics.push gated on `latest || allTimeCount > 0` like BodyFat already is — accounts with zero readings ever no longer get empty placeholder tiles. - 4 new regression tests in summary/__tests__/route.test.ts cover sparse accounts, zero-data accounts, within-7d guards. Other develop work bundled in this release: - W4-QoL — copy nits. - W5-WORKOUTS — user source priority threaded through write-time picker + batch route. - W7-WITHINGS-RELIABILITY — response classifier + sync hardening. - W8-OPS — ops phase docs. - B11 — NEXT_PUBLIC_APP_VERSION build-arg routing so /api/version cannot drift from CI tag. - env-check workflow — manifest / example lockstep enforcement. Resolves PR #194 (squash-merge produced via local -X theirs strategy because GitHub's UI couldn't auto-resolve develop's post-v1.4.42 contiguous work against the v1.4.42 squash on main; resulting tree is byte-identical to develop's HEAD).
64 lines
2.7 KiB
TypeScript
64 lines
2.7 KiB
TypeScript
import { apiHandler } from "@/lib/api-handler";
|
|
import { apiSuccess } from "@/lib/api-response";
|
|
import { offlineGeoReady } from "@/lib/geo";
|
|
import packageJson from "../../../../package.json";
|
|
|
|
// v1.4.27 R5 — `offlineGeoEnabled` reads from the same source the geo
|
|
// resolver uses for the runtime fallback gate, so the public state and
|
|
// the runtime behaviour cannot disagree. The check hits the filesystem
|
|
// (`existsSync` on the `.empty` marker + the City MMDB) which forces
|
|
// the route to be dynamic — the previous `force-static` setting would
|
|
// have frozen the answer at build time.
|
|
export const dynamic = "force-dynamic";
|
|
|
|
/**
|
|
* GET /api/version
|
|
*
|
|
* Public endpoint exposing the running build's version. Used by the
|
|
* Settings → About surface, the footer of every page, the
|
|
* "Check for updates" button (which compares against the GHCR API),
|
|
* and the admin status-summary row that surfaces the offline-geo
|
|
* availability state.
|
|
*
|
|
* The build SHA and built-at timestamp come from environment variables
|
|
* baked at image build time:
|
|
* - `NEXT_PUBLIC_APP_BUILD_SHA` — short Git SHA, set by the
|
|
* `docker-publish` workflow.
|
|
* - `NEXT_PUBLIC_APP_BUILT_AT` — ISO-8601 build timestamp, same
|
|
* workflow.
|
|
*
|
|
* For local `pnpm dev` neither is set; the route returns `null` and
|
|
* the UI falls back to "development" wording.
|
|
*
|
|
* `offlineGeoEnabled` is `true` when the GeoLite2-City MMDB is present
|
|
* at the configured `GEOLITE2_DIR` and no `.empty` marker is set.
|
|
* When `false` the runtime falls back to the online `ipwho.is`
|
|
* provider and the resolver emits a one-shot admin notification on
|
|
* first use.
|
|
*/
|
|
export const GET = apiHandler(async () => {
|
|
// v1.4.43 B11 — prefer the build-arg-injected env var so the runtime
|
|
// version cannot drift from the CI release tag. The Dockerfile takes
|
|
// `NEXT_PUBLIC_APP_VERSION` as a build arg from the docker-publish
|
|
// workflow (`build-args: NEXT_PUBLIC_APP_VERSION=${{ github.ref_name
|
|
// }}`); when present it wins over the package.json fallback so a
|
|
// BuildKit-layer cache hit on `pnpm build` can never re-ship the
|
|
// prior release's version string. Local `pnpm dev` (env unset) falls
|
|
// through to package.json as before.
|
|
const version = process.env.NEXT_PUBLIC_APP_VERSION?.trim() || packageJson.version;
|
|
const buildSha = process.env.NEXT_PUBLIC_APP_BUILD_SHA?.trim() || null;
|
|
const builtAt = process.env.NEXT_PUBLIC_APP_BUILT_AT?.trim() || null;
|
|
const offlineGeoEnabled = offlineGeoReady();
|
|
|
|
return apiSuccess({
|
|
version,
|
|
buildSha,
|
|
builtAt,
|
|
license: "AGPL-3.0",
|
|
repository: "https://github.com/MBombeck/HealthLog",
|
|
changelog: "https://github.com/MBombeck/HealthLog/blob/main/CHANGELOG.md",
|
|
docs: "https://docs.healthlog.dev",
|
|
offlineGeoEnabled,
|
|
});
|
|
});
|