From b75771a445970a331e1fb67fd87a0f2ac7808b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 18 Jul 2026 18:04:26 +0200 Subject: [PATCH 1/2] perf(medications): index the dashboard meds-today read shapes Two additive indexes on medication_intake_events: (user_id, scheduled_for) for the sibling reads that filter without medication_id, and (user_id, medication_id, taken_at) for the per-medication last-taken group-by that scanned the whole intake history on every dashboard load. Additive migration 0253, no data change, no behaviour change. --- .../0253_perf_medication_intake_indexes/migration.sql | 11 +++++++++++ prisma/schema.prisma | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 prisma/migrations/0253_perf_medication_intake_indexes/migration.sql diff --git a/prisma/migrations/0253_perf_medication_intake_indexes/migration.sql b/prisma/migrations/0253_perf_medication_intake_indexes/migration.sql new file mode 100644 index 000000000..217b1b8c3 --- /dev/null +++ b/prisma/migrations/0253_perf_medication_intake_indexes/migration.sql @@ -0,0 +1,11 @@ +-- v1.30.12 perf — index the two medication-intake read shapes the dashboard +-- "meds today" builder fires that could not index-seek before: the sibling +-- reads filtering (user_id, scheduled_for) without medication_id, and the +-- per-medication last-taken group-by that scanned the whole intake history. +-- Additive; no data change. + +-- CreateIndex +CREATE INDEX "medication_intake_events_user_id_scheduled_for_idx" ON "medication_intake_events"("user_id", "scheduled_for"); + +-- CreateIndex +CREATE INDEX "medication_intake_events_user_id_medication_id_taken_at_idx" ON "medication_intake_events"("user_id", "medication_id", "taken_at"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 31162b780..ca42d421f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2733,6 +2733,12 @@ model MedicationIntakeEvent { // v1.7.0 sync — keyset support for the `/api/sync/changes` intake feed // (`where userId` ordered by `(updatedAt asc, id asc)`). @@index([userId, updatedAt, id]) + // v1.30.12 perf — the dashboard "meds today" read fires sibling queries that + // filter `(userId, scheduledFor)` WITHOUT `medicationId` (the composite above + // cannot range-seek those) and a per-medication `_max(takenAt)` group-by that + // scanned the whole intake history. These two let both index-seek instead. + @@index([userId, scheduledFor]) + @@index([userId, medicationId, takenAt]) @@map("medication_intake_events") } From 9e2c445ad7d3f4b9c220eafcaf319f754f865b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 18 Jul 2026 18:04:41 +0200 Subject: [PATCH 2/2] =?UTF-8?q?chore(release):=20v1.30.12=20=E2=80=94=20in?= =?UTF-8?q?dex=20the=20dashboard=20medication=20reads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ docs/api/openapi.yaml | 2 +- package.json | 2 +- public/sw.js | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e35f0557f..1e9b8265d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased] +## [1.30.12] — 2026-07-18 + +Faster medication reads. + +- **The dashboard's medication section stays fast as your log grows.** Its reads now use dedicated indexes instead of scanning the full intake history on every load, so a long history no longer slows down the daily view. + +No breaking changes. + ## [1.30.11] — 2026-07-18 Native single sign-on. diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml index 0e21fe47a..80c739eae 100644 --- a/docs/api/openapi.yaml +++ b/docs/api/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: HealthLog API - version: 1.30.11 + version: 1.30.12 description: >- Self-hosted personal-health-tracking PWA — public API surface for the iOS native client and external ingest. diff --git a/package.json b/package.json index bab013441..357f48648 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "healthlog", - "version": "1.30.11", + "version": "1.30.12", "description": "Self-hosted personal-health-tracking PWA with Withings integration, AI insights, and doctor-report PDF export.", "license": "PolyForm-Noncommercial-1.0.0", "homepage": "https://healthlog.dev", diff --git a/public/sw.js b/public/sw.js index cb9fda04d..36dccca52 100644 --- a/public/sw.js +++ b/public/sw.js @@ -36,7 +36,7 @@ try { // v1.4.38.4 → v1.4.42. Do not hand-edit; bump `package.json` and rebuild. const CACHE_VERSION = (typeof self !== "undefined" && self.__APP_VERSION__) || - /* @sw-version-fallback */ "v1.30.11"; + /* @sw-version-fallback */ "v1.30.12"; const STATIC_CACHE = `healthlog-static-${CACHE_VERSION}`; const PAGE_CACHE = `healthlog-pages-${CACHE_VERSION}`; // v1.18.6 — read-only data cache for a curated allowlist of safe GET `/api/*`