feat(watch): use HealthKit lap detection and track stroke count/swolf
This commit is contained in:
@@ -146,6 +146,7 @@ export async function saveWatchCompletedWorkout(data: {
|
||||
distance: number;
|
||||
duration: number;
|
||||
heartRate: number;
|
||||
strokeCount?: number;
|
||||
}>;
|
||||
}) {
|
||||
const avgHeartRate =
|
||||
@@ -186,6 +187,9 @@ export async function saveWatchCompletedWorkout(data: {
|
||||
}
|
||||
|
||||
for (const lap of data.laps) {
|
||||
const strokeCount = lap.strokeCount ?? null;
|
||||
const swolf = strokeCount != null ? strokeCount + Math.round(lap.duration) : null;
|
||||
|
||||
await db.insert(laps).values({
|
||||
id: generateUUID(),
|
||||
workoutId: data.workoutId,
|
||||
@@ -194,8 +198,8 @@ export async function saveWatchCompletedWorkout(data: {
|
||||
distance: lap.distance,
|
||||
duration: lap.duration,
|
||||
heartRate: lap.heartRate || null,
|
||||
strokeCount: null,
|
||||
swolf: null,
|
||||
strokeCount,
|
||||
swolf,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user