Skip to content

Commit 17ca32b

Browse files
committed
fix: update workoutSubTypeId handling in CreateTPWorkoutRequestDTO and add logging in TrainingPeaksWorkoutRepository
1 parent f0d4c15 commit 17ca32b

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

boot/src/main/kotlin/org/freekode/tp2intervals/infrastructure/platform/trainingpeaks/workout/CreateTPWorkoutRequestDTO.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CreateTPWorkoutRequestDTO(
88
var athleteId: String,
99
var workoutDay: LocalDate,
1010
var workoutTypeValueId: Int,
11-
var workoutSubTypeValueId: Int?,
11+
var workoutSubTypeId: Int,
1212
var title: String,
1313
var description: String?,
1414
var totalTime: Double?,
@@ -31,17 +31,17 @@ class CreateTPWorkoutRequestDTO(
3131
athleteId: String, workout: Workout, structureStr: String?
3232
): CreateTPWorkoutRequestDTO {
3333
return CreateTPWorkoutRequestDTO(
34-
athleteId,
35-
workout.date ?: LocalDate.now(),
36-
TPTrainingTypeMapper.getByType(workout.details.type),
37-
49, // TODO: Map workout subtype to TrainingPeaks subtype value ID
38-
workout.details.name,
39-
buildDescription(workout),
40-
null,
41-
workout.details.duration?.toMinutes()?.toDouble()?.div(60),
42-
null,
43-
workout.details.load,
44-
structureStr
34+
athleteId = athleteId,
35+
workoutDay = workout.date ?: LocalDate.now(),
36+
workoutTypeValueId = TPTrainingTypeMapper.getByType(workout.details.type),
37+
workoutSubTypeId = 49,
38+
title = workout.details.name,
39+
description = buildDescription(workout),
40+
plannedWorkoutId = null,
41+
totalTimePlanned = workout.details.duration?.toMinutes()?.toDouble()?.div(60),
42+
distancePlanned = null,
43+
tssPlanned = workout.details.load,
44+
structure = structureStr
4545
)
4646
}
4747

boot/src/main/kotlin/org/freekode/tp2intervals/infrastructure/platform/trainingpeaks/workout/TrainingPeaksWorkoutRepository.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ class TrainingPeaksWorkoutRepository(
132132
)
133133
log.debug("Creating TrainingPeaks workout {}, target preview: {}", workout.details.name, targetPreview(workout))
134134
log.debug("TrainingPeaks structure preview for {}: {}", workout.details.name, structureStr?.take(600))
135+
136+
log.info(
137+
"Creating TP workout '{}'. workoutTypeValueId={}, workoutSubTypeId={}",
138+
createRequest.title,
139+
createRequest.workoutTypeValueId,
140+
createRequest.workoutSubTypeId
141+
)
142+
135143
trainingPeaksApiClient.createAndPlanWorkout(athleteId, createRequest)
136144
}
137145

0 commit comments

Comments
 (0)