feat(exercises): update to version 0.8.100 and enhance combination exercise handling
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 56s
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 56s
- Bumped app version to 0.8.100, reflecting recent updates. - Improved validation logic for combination exercises in the backend, ensuring proper handling of exercise variants. - Enhanced frontend components, including the ExercisePickerModal, to support filtering and displaying combination exercises. - Updated API payloads and utility functions to accommodate new exercise types and their properties. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a9f9f960f
commit
3dc4c9c79e
7 files changed
+162
-54
No files matched your search
@@ -71,7 +71,9 @@ export function sectionsToPutPayload(unit, durationOverridesByItemId = {}) {
|
||||
if (eid === '' || eid == null || Number.isNaN(Number(eid))) {
|
||||
return null
|
||||
}
|
||||
const vid = it.exercise_variant_id
|
||||
const isCombo =
|
||||
String(it.exercise_kind || 'simple').toLowerCase().trim() === 'combination'
|
||||
const vid = isCombo ? null : it.exercise_variant_id
|
||||
let actual =
|
||||
durationOverridesByItemId[String(it.id)]?.actual_duration_min ??
|
||||
it.actual_duration_min
|
||||
|
||||
@@ -9,6 +9,7 @@ export function exerciseRow() {
|
||||
item_type: 'exercise',
|
||||
exercise_id: '',
|
||||
exercise_variant_id: '',
|
||||
exercise_kind: 'simple',
|
||||
exercise_title: '',
|
||||
variants: [],
|
||||
planned_duration_min: '',
|
||||
@@ -23,22 +24,31 @@ export function exerciseRow() {
|
||||
export async function hydrateExercisePlanningRow(exercise) {
|
||||
let variants = Array.isArray(exercise?.variants) ? exercise.variants : []
|
||||
let title = exercise?.title || ''
|
||||
let exerciseKind = exercise?.exercise_kind
|
||||
const id = exercise?.id
|
||||
if (!id) return null
|
||||
let meta = {}
|
||||
if (!variants.length) {
|
||||
|
||||
async function fetchFull() {
|
||||
try {
|
||||
const full = await api.getExercise(id)
|
||||
variants = Array.isArray(full?.variants) ? full.variants : []
|
||||
title = full?.title || title
|
||||
meta = {
|
||||
exercise_visibility: full?.visibility || 'private',
|
||||
exercise_club_id: full?.club_id ?? null,
|
||||
exercise_created_by: full?.created_by ?? null,
|
||||
exercise_status: full?.status || 'draft',
|
||||
}
|
||||
return await api.getExercise(id)
|
||||
} catch {
|
||||
variants = []
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
if (!variants.length) {
|
||||
const full = await fetchFull()
|
||||
if (full) {
|
||||
variants = Array.isArray(full.variants) ? full.variants : []
|
||||
title = full.title || title
|
||||
if (exerciseKind == null) exerciseKind = full.exercise_kind
|
||||
meta = {
|
||||
exercise_visibility: full.visibility || 'private',
|
||||
exercise_club_id: full.club_id ?? null,
|
||||
exercise_created_by: full.created_by ?? null,
|
||||
exercise_status: full.status || 'draft',
|
||||
}
|
||||
}
|
||||
} else {
|
||||
meta = {
|
||||
@@ -47,25 +57,37 @@ export async function hydrateExercisePlanningRow(exercise) {
|
||||
exercise_created_by: exercise?.created_by ?? null,
|
||||
exercise_status: exercise?.status ?? null,
|
||||
}
|
||||
if (meta.exercise_visibility == null || meta.exercise_created_by == null) {
|
||||
try {
|
||||
const full = await api.getExercise(id)
|
||||
if (meta.exercise_visibility == null) meta.exercise_visibility = full?.visibility || 'private'
|
||||
if (meta.exercise_club_id == null) meta.exercise_club_id = full?.club_id ?? null
|
||||
if (meta.exercise_created_by == null) meta.exercise_created_by = full?.created_by ?? null
|
||||
if (meta.exercise_status == null) meta.exercise_status = full?.status || 'draft'
|
||||
} catch {
|
||||
/* keep partial meta */
|
||||
if (
|
||||
meta.exercise_visibility == null ||
|
||||
meta.exercise_created_by == null ||
|
||||
exerciseKind == null
|
||||
) {
|
||||
const full = await fetchFull()
|
||||
if (full) {
|
||||
if (meta.exercise_visibility == null) meta.exercise_visibility = full.visibility || 'private'
|
||||
if (meta.exercise_club_id == null) meta.exercise_club_id = full.club_id ?? null
|
||||
if (meta.exercise_created_by == null) meta.exercise_created_by = full.created_by ?? null
|
||||
if (meta.exercise_status == null) meta.exercise_status = full.status || 'draft'
|
||||
if (exerciseKind == null) exerciseKind = full.exercise_kind
|
||||
if (!variants.length) variants = Array.isArray(full.variants) ? full.variants : []
|
||||
}
|
||||
}
|
||||
meta.exercise_visibility = meta.exercise_visibility || 'private'
|
||||
meta.exercise_status = meta.exercise_status || 'draft'
|
||||
}
|
||||
|
||||
const row = exerciseRow()
|
||||
row.exercise_id = id
|
||||
row.exercise_variant_id = ''
|
||||
row.exercise_title = title
|
||||
row.variants = variants
|
||||
row.exercise_kind =
|
||||
String(exerciseKind || 'simple').toLowerCase().trim() === 'combination' ? 'combination' : 'simple'
|
||||
if (row.exercise_kind === 'combination') {
|
||||
row.variants = []
|
||||
row.exercise_variant_id = ''
|
||||
} else {
|
||||
row.variants = variants
|
||||
}
|
||||
Object.assign(row, meta)
|
||||
return row
|
||||
}
|
||||
@@ -106,10 +128,13 @@ export function normalizeUnitToForm(fullUnit) {
|
||||
return rowNote
|
||||
}
|
||||
const smEx = parseOptionalSourceTrainingModuleIdForPayload(it.source_training_module_id)
|
||||
const ek = String(it.exercise_kind || 'simple').toLowerCase().trim()
|
||||
const isCombo = ek === 'combination'
|
||||
return {
|
||||
item_type: 'exercise',
|
||||
exercise_id: it.exercise_id,
|
||||
exercise_variant_id: it.exercise_variant_id ?? '',
|
||||
exercise_kind: isCombo ? 'combination' : 'simple',
|
||||
exercise_variant_id: isCombo ? '' : it.exercise_variant_id ?? '',
|
||||
exercise_title: it.exercise_title || '',
|
||||
variants: [],
|
||||
planned_duration_min:
|
||||
@@ -141,23 +166,28 @@ export function normalizeUnitToForm(fullUnit) {
|
||||
{
|
||||
title: 'Übungen',
|
||||
guidance_notes: '',
|
||||
items: fullUnit.exercises.map((ex) => ({
|
||||
item_type: 'exercise',
|
||||
exercise_id: ex.exercise_id,
|
||||
exercise_variant_id: ex.exercise_variant_id ?? '',
|
||||
exercise_title: ex.exercise_title || '',
|
||||
variants: [],
|
||||
planned_duration_min:
|
||||
ex.planned_duration_min !== null && ex.planned_duration_min !== undefined
|
||||
? String(ex.planned_duration_min)
|
||||
: '',
|
||||
actual_duration_min:
|
||||
ex.actual_duration_min !== null && ex.actual_duration_min !== undefined
|
||||
? String(ex.actual_duration_min)
|
||||
: '',
|
||||
notes: ex.notes ?? '',
|
||||
modifications: ex.modifications ?? '',
|
||||
})),
|
||||
items: fullUnit.exercises.map((ex) => {
|
||||
const ek = String(ex.exercise_kind || 'simple').toLowerCase().trim()
|
||||
const isCombo = ek === 'combination'
|
||||
return {
|
||||
item_type: 'exercise',
|
||||
exercise_kind: ek,
|
||||
exercise_id: ex.exercise_id,
|
||||
exercise_variant_id: isCombo ? '' : (ex.exercise_variant_id ?? ''),
|
||||
exercise_title: ex.exercise_title || '',
|
||||
variants: [],
|
||||
planned_duration_min:
|
||||
ex.planned_duration_min !== null && ex.planned_duration_min !== undefined
|
||||
? String(ex.planned_duration_min)
|
||||
: '',
|
||||
actual_duration_min:
|
||||
ex.actual_duration_min !== null && ex.actual_duration_min !== undefined
|
||||
? String(ex.actual_duration_min)
|
||||
: '',
|
||||
notes: ex.notes ?? '',
|
||||
modifications: ex.modifications ?? '',
|
||||
}
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -181,6 +211,7 @@ export async function enrichSectionsWithVariants(sections) {
|
||||
const ex = await api.getExercise(id)
|
||||
cache.set(id, {
|
||||
title: ex.title || '',
|
||||
exercise_kind: String(ex.exercise_kind || 'simple').toLowerCase().trim(),
|
||||
variants: Array.isArray(ex.variants) ? ex.variants : [],
|
||||
visibility: ex.visibility || 'private',
|
||||
club_id: ex.club_id ?? null,
|
||||
@@ -190,6 +221,7 @@ export async function enrichSectionsWithVariants(sections) {
|
||||
} catch {
|
||||
cache.set(id, {
|
||||
title: '',
|
||||
exercise_kind: 'simple',
|
||||
variants: [],
|
||||
visibility: 'private',
|
||||
club_id: null,
|
||||
@@ -206,11 +238,15 @@ export async function enrichSectionsWithVariants(sections) {
|
||||
if (!it.exercise_id) return it
|
||||
const c = cache.get(it.exercise_id)
|
||||
if (!c) return it
|
||||
const ek = String(c.exercise_kind || 'simple').toLowerCase().trim()
|
||||
const isCombo = ek === 'combination'
|
||||
return {
|
||||
...it,
|
||||
exercise_kind: isCombo ? 'combination' : 'simple',
|
||||
exercise_title: it.exercise_title || c.title,
|
||||
exercise_variant_id: isCombo ? '' : it.exercise_variant_id,
|
||||
variants:
|
||||
Array.isArray(it.variants) && it.variants.length > 0 ? it.variants : c.variants,
|
||||
isCombo ? [] : Array.isArray(it.variants) && it.variants.length > 0 ? it.variants : c.variants,
|
||||
exercise_visibility: c.visibility,
|
||||
exercise_club_id: c.club_id,
|
||||
exercise_created_by: c.created_by,
|
||||
@@ -246,7 +282,8 @@ export function buildSectionsPayload(sections) {
|
||||
if (it.exercise_id === '' || it.exercise_id == null || Number.isNaN(Number(it.exercise_id))) {
|
||||
return null
|
||||
}
|
||||
const vid = it.exercise_variant_id
|
||||
const isCombo = String(it.exercise_kind || 'simple').toLowerCase().trim() === 'combination'
|
||||
const vid = isCombo ? null : it.exercise_variant_id
|
||||
const smEx = parseOptionalSourceTrainingModuleIdForPayload(it.source_training_module_id)
|
||||
const rowEx = {
|
||||
item_type: 'exercise',
|
||||
@@ -320,7 +357,12 @@ export async function insertTrainingModuleIntoPlanningSections({
|
||||
if (!hydrated) continue
|
||||
hydrated.source_training_module_id = midNum
|
||||
hydrated.source_module_title = modTitle
|
||||
if (mi.exercise_variant_id) hydrated.exercise_variant_id = String(mi.exercise_variant_id)
|
||||
if (
|
||||
hydrated.exercise_kind !== 'combination' &&
|
||||
mi.exercise_variant_id
|
||||
) {
|
||||
hydrated.exercise_variant_id = String(mi.exercise_variant_id)
|
||||
}
|
||||
hydrated.planned_duration_min =
|
||||
mi.planned_duration_min !== null && mi.planned_duration_min !== undefined
|
||||
? String(mi.planned_duration_min)
|
||||
|
||||
Reference in new issue
Block a user