docs(workout): TODO for cross-source workout dedup at v1.5 iOS landing

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.
This commit is contained in:
Marc-André Bombeck committed 2026-05-14 16:52:52 +02:00
1 parent 2bb49ae764
commit cf5d6c433a
1 file changed
+10
+10
View File
@@ -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])