From cf5d6c433aff07bc14f778c8d390acfafaf2e415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 14 May 2026 16:52:52 +0200 Subject: [PATCH] docs(workout): TODO for cross-source workout dedup at v1.5 iOS landing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Workout uniqueness key is (userId, source, externalId). The same workout ingested from MANUAL plus the iOS HealthKit passthrough lands two rows because `source` differs — Postgres NULL-distinct semantics keep manual workouts unique among themselves, but the cross-source case has no canonical-picker layer yet. Measurements already solved the symmetric problem via the W8c canonical-source picker. Workouts need the same shape before the dashboard "recent workouts" tile can show one row per workout instead of one per source. Schema-only release today (W8d), and there is no iOS client yet, so the smell is latent — track it inline on the model so the v1.5 iOS sprint picks it up. --- prisma/schema.prisma | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 39b64ef15..b27ad21fe 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -421,6 +421,16 @@ model Workout { /// Ingest dedup. NULL externalId is distinct so two manual /// entries on the same day never collide here. + /// + /// TODO(v1.5 iOS): cross-source workout dedup. The current key is + /// (userId, source, externalId) — so the SAME workout ingested from + /// MANUAL plus the iOS HealthKit passthrough lands two rows because + /// `source` differs. Measurements already solved this via + /// `pickCanonicalSourceRows()` (the read-time canonical-source + /// picker in src/lib/analytics/source-priority.ts); workouts need + /// the symmetric helper before the dashboard "recent workouts" tile + /// can show one row per workout instead of one per source. Tracked + /// for v1.5 P1 alongside the iOS app. @@unique([userId, source, externalId]) /// Dashboard "recent workouts" query path. @@index([userId, startedAt])