Enhance Training Framework Programs with Session Duration and Filtering Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m29s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m29s
- Added SQL aggregations for session duration (min/max) and goal titles in the training framework programs query. - Updated the TrainingPlanningFrameworkImportModal component to include filtering options for focus areas, training types, and target groups. - Implemented session duration display in the TrainingFrameworkProgramsListPage, improving user visibility of program details. - Introduced utility functions for formatting session duration ranges, enhancing the overall user experience in training planning.
This commit is contained in:
1 parent
5a8a212f40
commit
9353909fda
7 files changed
+450
-14
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import { formatSessionDurationRange } from './trainingDurationUtils'
|
||||
|
||||
export function frameworkSessionDurationLabel(row) {
|
||||
return formatSessionDurationRange(row?.session_duration_min, row?.session_duration_max, {
|
||||
empty: 'Dauer nicht angegeben',
|
||||
})
|
||||
}
|
||||
|
||||
function parseIdList(raw) {
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.map((x) => String(x)).filter(Boolean)
|
||||
}
|
||||
if (typeof raw === 'string' && raw.trim().startsWith('[')) {
|
||||
try {
|
||||
const arr = JSON.parse(raw)
|
||||
if (Array.isArray(arr)) return arr.map((x) => String(x))
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
function rowMatchesDuration(row, targetMin, toleranceMin = 10) {
|
||||
if (targetMin == null || targetMin === '' || Number.isNaN(Number(targetMin))) return true
|
||||
const t = Number(targetMin)
|
||||
const lo = row.session_duration_min != null ? Number(row.session_duration_min) : null
|
||||
const hi = row.session_duration_max != null ? Number(row.session_duration_max) : null
|
||||
if (lo == null && hi == null) return true
|
||||
if (lo != null && hi != null) {
|
||||
return t >= lo - toleranceMin && t <= hi + toleranceMin
|
||||
}
|
||||
const single = lo ?? hi
|
||||
return single != null && Math.abs(single - t) <= toleranceMin
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-Filter für Rahmenprogramm-Auswahl (Liste / Import-Dialog).
|
||||
*/
|
||||
export function filterFrameworkPrograms(rows, filters = {}) {
|
||||
const q = (filters.query || '').trim().toLowerCase()
|
||||
const focusIds = new Set((filters.focusAreaIds || []).map(String))
|
||||
const typeIds = new Set((filters.trainingTypeIds || []).map(String))
|
||||
const tgIds = new Set((filters.targetGroupIds || []).map(String))
|
||||
const durationTarget = filters.durationTargetMin
|
||||
|
||||
return (rows || []).filter((r) => {
|
||||
if (q) {
|
||||
const blob = [
|
||||
r.title,
|
||||
r.description,
|
||||
r.goal_titles_agg,
|
||||
r.focus_area_names_agg,
|
||||
r.style_direction_names_agg,
|
||||
r.training_type_names_agg,
|
||||
r.target_group_names_agg,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
if (!blob.includes(q)) return false
|
||||
}
|
||||
|
||||
if (focusIds.size) {
|
||||
const fa = parseIdList(r.focus_area_ids)
|
||||
if (!fa.some((id) => focusIds.has(id))) return false
|
||||
}
|
||||
if (typeIds.size) {
|
||||
const tt = parseIdList(r.training_type_ids)
|
||||
if (!tt.some((id) => typeIds.has(id))) return false
|
||||
}
|
||||
if (tgIds.size) {
|
||||
const tg = parseIdList(r.target_group_ids)
|
||||
if (!tg.some((id) => tgIds.has(id))) return false
|
||||
}
|
||||
|
||||
if (!rowMatchesDuration(r, durationTarget)) return false
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
export function frameworkProgramOptionLabel(row) {
|
||||
const title = (row?.title || '').trim() || `Rahmen #${row?.id}`
|
||||
const dur = frameworkSessionDurationLabel(row)
|
||||
const slots = row?.slots_count != null ? `${row.slots_count} Slot(s)` : ''
|
||||
const bits = [dur !== 'Dauer nicht angegeben' ? dur : null, slots].filter(Boolean)
|
||||
return bits.length ? `${title} · ${bits.join(' · ')}` : title
|
||||
}
|
||||
Reference in new issue
Block a user