|
|
@ -85,7 +85,7 @@ class Workout { |
|
|
|
|
|
|
|
this.repo.insertMeasurement({...ws, workoutId: this.id}); |
|
|
|
|
|
|
|
this.events.emit("workoutStatus", ws); |
|
|
|
this.events.emit("workoutStatus", {...ws}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -95,7 +95,14 @@ class Workout { |
|
|
|
*/ |
|
|
|
static async create(repo, bikeId, programId) { |
|
|
|
const bike = await repo.findBike(bikeId); |
|
|
|
if (bike == null) { |
|
|
|
throw new Error("bike not found"); |
|
|
|
} |
|
|
|
const program = await repo.findProgram(programId); |
|
|
|
if (program == null) { |
|
|
|
throw new Error("program not found"); |
|
|
|
} |
|
|
|
|
|
|
|
const date = new Date(); |
|
|
|
const id = await repo.insertWorkout({ |
|
|
|
bikeId: bike.id, |
|
|
@ -115,7 +122,7 @@ class Workout { |
|
|
|
const bike = await repo.findBike(data.bikeId); |
|
|
|
const program = await repo.findWorkout(data.workoutId); |
|
|
|
|
|
|
|
const workout = new Workout(repo, parseInt(id), bike, program, new Date(data.date)); |
|
|
|
const workout = new Workout(repo, id, bike, program, new Date(data.date)); |
|
|
|
|
|
|
|
const list = await repo.listMeasurements(id); |
|
|
|
if (list.length > 0) { |
|
|
|