mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
fix(workouts): share enriched canonical detail data
This commit is contained in:
1 parent
ed63a3bf32
commit
43cce08012
2 files changed
+14
-3
No files matched your search
@@ -114,6 +114,9 @@ export const GET = apiHandler(
|
||||
source: true,
|
||||
startedAt: true,
|
||||
sportType: true,
|
||||
avgHeartRate: true,
|
||||
maxHeartRate: true,
|
||||
metadata: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -132,6 +135,10 @@ export const GET = apiHandler(
|
||||
canonicalCluster.find((c) => c.id === row.id) ??
|
||||
canonicalCluster[0] ??
|
||||
null;
|
||||
const effectiveAvgHeartRate =
|
||||
canonical?.avgHeartRate ?? row.avgHeartRate;
|
||||
const effectiveMaxHeartRate =
|
||||
canonical?.maxHeartRate ?? row.maxHeartRate;
|
||||
|
||||
// ── Enrichment reads (all over existing tables — no migration) ────
|
||||
|
||||
@@ -159,7 +166,9 @@ export const GET = apiHandler(
|
||||
hrMax: hrMaxFromAge(ageYears),
|
||||
series: hrSeries?.points ?? [],
|
||||
bucketSec: hrSeries?.bucketSec ?? 0,
|
||||
whoopZoneDurations: parseWhoopZoneDurations(row.metadata),
|
||||
whoopZoneDurations: parseWhoopZoneDurations(
|
||||
canonical?.metadata ?? row.metadata,
|
||||
),
|
||||
});
|
||||
|
||||
// Per-km splits computed server-side from the geometry + timestamps
|
||||
@@ -241,8 +250,8 @@ export const GET = apiHandler(
|
||||
durationSec: row.durationSec,
|
||||
distanceM: row.totalDistanceM,
|
||||
activeEnergyKcal: row.totalEnergyKcal,
|
||||
avgHr: row.avgHeartRate,
|
||||
maxHr: row.maxHeartRate,
|
||||
avgHr: effectiveAvgHeartRate,
|
||||
maxHr: effectiveMaxHeartRate,
|
||||
minHr: row.minHeartRate,
|
||||
stepCount: row.stepCount,
|
||||
elevationM: row.elevationM,
|
||||
|
||||
@@ -77,6 +77,7 @@ interface CanonicalWorkoutRow {
|
||||
totalEnergyKcal: number | null;
|
||||
avgHeartRate: number | null;
|
||||
maxHeartRate: number | null;
|
||||
metadata: unknown;
|
||||
createdAt: Date;
|
||||
// #67 list glyphs — cheap relation-id selects so the list can flag
|
||||
// which sessions open into a rich detail (map / HR curve).
|
||||
@@ -158,6 +159,7 @@ export async function buildWorkoutsProjection(
|
||||
totalEnergyKcal: true,
|
||||
avgHeartRate: true,
|
||||
maxHeartRate: true,
|
||||
metadata: true,
|
||||
createdAt: true,
|
||||
route: { select: { id: true } },
|
||||
samples: { select: { sampleCount: true } },
|
||||
|
||||
Reference in new issue
Block a user