Implement Phase 3 Features for Skill Profiles and Discovery
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 38s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m27s

- Updated the framework program documentation to reflect the completion of Phase 3 v1.0, including new skill scoring and API enhancements.
- Added new API endpoints for skill profile retrieval and suggestions, improving the ability to aggregate and display skills based on training data.
- Introduced new UI components for skill profiles and discovery in the frontend, enhancing user interaction with training frameworks and skills.
- Updated version information to 0.8.151, reflecting the addition of skill profiles and related features.
This commit is contained in:
Lars committed 2026-05-20 16:42:25 +02:00
1 parent e382b6ed35
commit 732b322c52
16 files changed
+1626 -17

No files matched your search

@@ -5,6 +5,7 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { Link } from 'react-router-dom'
import api from '../utils/api'
import SkillProfilePanel from './skills/SkillProfilePanel'
import { useAuth } from '../context/AuthContext'
import { getTenantClubDependencyKey } from '../utils/activeClub'
import ExercisePickerModal from './ExercisePickerModal'
@@ -136,6 +137,9 @@ export default function ExerciseProgressionGraphPanel({
const [editingEdgeNotes, setEditingEdgeNotes] = useState(null)
const [notesDraft, setNotesDraft] = useState('')
const [uiTab, setUiTab] = useState('overview')
const [skillProfileData, setSkillProfileData] = useState(null)
const [skillProfileLoading, setSkillProfileLoading] = useState(false)
const [skillProfileError, setSkillProfileError] = useState('')
useEffect(() => {
setSelectedGraphId(null)
@@ -180,6 +184,32 @@ export default function ExerciseProgressionGraphPanel({
}
}, [refreshGraphs, tenantClubDepKey])
useEffect(() => {
if (!selectedGraphId) {
setSkillProfileData(null)
return undefined
}
let cancelled = false
;(async () => {
setSkillProfileLoading(true)
setSkillProfileError('')
try {
const data = await api.getProgressionGraphSkillProfile(selectedGraphId)
if (!cancelled) setSkillProfileData(data)
} catch (e) {
if (!cancelled) {
setSkillProfileData(null)
setSkillProfileError(e.message || 'Fähigkeiten-Profil nicht geladen')
}
} finally {
if (!cancelled) setSkillProfileLoading(false)
}
})()
return () => {
cancelled = true
}
}, [selectedGraphId, edges.length])
useEffect(() => {
if (!selectedGraphId) {
setEdges([])
@@ -652,6 +682,14 @@ export default function ExerciseProgressionGraphPanel({
{selectedGraphId && uiTab === 'overview' && (
<>
<SkillProfilePanel
title="Fähigkeiten entlang des Pfads"
hint="Alle Übungen als Knoten im Graph (ohne Einzel-Dauer — Standardgewicht pro Übung)."
profile={skillProfileData?.overall}
loading={skillProfileLoading}
error={skillProfileError}
defaultExpanded
/>
<div className="card" style={{ marginBottom: '12px' }}>
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>Sequenz / Reihe anlegen</h3>
<p style={{ fontSize: '12px', color: 'var(--text3)', marginTop: 0 }}>
@@ -0,0 +1,163 @@
import React, { useMemo, useState } from 'react'
import { Link } from 'react-router-dom'
import api from '../../utils/api'
const ARTIFACT_LABELS = {
framework_program: 'Rahmenprogramm',
training_module: 'Trainingsmodul',
progression_graph: 'Regressionspfad',
}
/**
* Vorschläge für Planungsartefakte anhand gewählter Fähigkeiten (Phase 3).
*/
export default function SkillDiscoveryPanel({ skills = [] }) {
const [selectedIds, setSelectedIds] = useState([])
const [query, setQuery] = useState('')
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [result, setResult] = useState(null)
const filteredSkills = useMemo(() => {
const q = query.trim().toLowerCase()
const list = (skills || []).filter((s) => s.status !== 'inactive')
if (!q) return list
return list.filter(
(s) =>
(s.name || '').toLowerCase().includes(q) ||
(s.category || '').toLowerCase().includes(q)
)
}, [skills, query])
const toggleSkill = (id) => {
const s = String(id)
setSelectedIds((prev) =>
prev.includes(s) ? prev.filter((x) => x !== s) : [...prev, s]
)
}
async function handleSearch() {
const ids = selectedIds.map((x) => parseInt(x, 10)).filter((n) => n > 0)
if (!ids.length) {
setError('Wähle mindestens eine Fähigkeit.')
return
}
setLoading(true)
setError('')
setResult(null)
try {
const data = await api.getSkillDiscoverySuggestions(ids, { limit: 25 })
setResult(data)
} catch (e) {
setError(e.message || 'Suche fehlgeschlagen')
} finally {
setLoading(false)
}
}
return (
<div className="skill-discovery card">
<h2 className="skill-discovery__title">Planungs-Vorschläge</h2>
<p className="form-sub skill-discovery__lead">
Wähle Fähigkeiten, die du schwerpunktmäßig entwickeln willst — Shinkan schlägt passende
Rahmenprogramme, Trainingsmodule und Regressionspfade aus der Bibliothek vor (gewichtet nach
Übungs-Verknüpfungen).
</p>
<div className="form-row">
<label className="form-label">Fähigkeiten filtern</label>
<input
className="form-input"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Name oder Kategorie …"
/>
</div>
<div className="skill-discovery__pick-grid" role="group" aria-label="Fähigkeiten auswählen">
{filteredSkills.length === 0 ? (
<p className="form-sub">Keine Fähigkeiten gefunden.</p>
) : (
filteredSkills.map((sk) => (
<label key={sk.id} className="skill-discovery__pick">
<input
type="checkbox"
checked={selectedIds.includes(String(sk.id))}
onChange={() => toggleSkill(sk.id)}
/>
<span className="skill-discovery__pick-name">{sk.name}</span>
{sk.category ? (
<span className="skill-discovery__pick-cat">{sk.category}</span>
) : null}
</label>
))
)}
</div>
<div className="skill-discovery__actions">
<button
type="button"
className="btn btn-primary"
disabled={loading || selectedIds.length === 0}
onClick={handleSearch}
>
{loading ? 'Suche …' : 'Bibliothek durchsuchen'}
</button>
{selectedIds.length > 0 ? (
<button
type="button"
className="btn btn-secondary"
onClick={() => {
setSelectedIds([])
setResult(null)
setError('')
}}
>
Auswahl leeren
</button>
) : null}
</div>
{error ? <p className="skill-discovery__error">{error}</p> : null}
{result?.suggestions?.length > 0 ? (
<ul className="skill-discovery__results">
{result.suggestions.map((item) => (
<li key={`${item.artifact_type}-${item.artifact_id}`} className="skill-discovery__result card">
<div className="skill-discovery__result-head">
<span className="skill-discovery__result-type">
{ARTIFACT_LABELS[item.artifact_type] || item.artifact_type}
</span>
<span className="skill-discovery__result-match">
Passung {item.match?.match_percent ?? 0}%
</span>
</div>
<strong className="skill-discovery__result-title">
{item.artifact_title || `#${item.artifact_id}`}
</strong>
{item.match?.matched_skills?.length > 0 ? (
<p className="skill-discovery__result-skills">
{item.match.matched_skills.map((m) => m.skill_name).join(' · ')}
</p>
) : null}
{item.path ? (
<Link to={item.path} className="btn btn-secondary btn-small skill-discovery__result-link">
Öffnen
</Link>
) : item.artifact_type === 'progression_graph' ? (
<p className="form-sub" style={{ margin: '8px 0 0' }}>
Regressionspfad in der Übungsliste unter „Progressionsgraph“ bearbeiten.
</p>
) : null}
</li>
))}
</ul>
) : result && !loading ? (
<p className="form-sub skill-discovery__no-hit">
Keine passenden Artefakte in deiner sichtbaren Bibliothek — prüfe Fähigkeiten-Verknüpfungen an
den Übungen oder erweitere die Auswahl.
</p>
) : null}
</div>
)
}
@@ -0,0 +1,189 @@
import React, { useMemo, useState } from 'react'
function SkillBar({ skill, maxShare }) {
const pct = maxShare > 0 ? Math.min(100, (skill.share_percent / maxShare) * 100) : 0
return (
<li className="skill-profile__row">
<div className="skill-profile__row-head">
<span className="skill-profile__name" title={skill.skill_name}>
{skill.skill_name}
</span>
<span className="skill-profile__pct">{skill.share_percent}%</span>
</div>
<div className="skill-profile__bar-track" aria-hidden="true">
<div
className="skill-profile__bar-fill"
style={{ width: `${pct}%` }}
/>
</div>
{skill.primary_link_count > 0 ? (
<span className="skill-profile__meta-hint">
{skill.primary_link_count}× als Primär-Fähigkeit in Übungen
</span>
) : null}
</li>
)
}
/**
* Gewichtetes Fähigkeiten-Profil (Phase 3) — Anzeige für Planungsartefakte.
*/
export default function SkillProfilePanel({
profile,
slots = null,
loading = false,
error = '',
title = 'Fähigkeiten-Profil',
hint = 'Aus verknüpften Übungen berechnet (Dauer, Vorkommen, Primär-Fähigkeit, Intensität).',
defaultExpanded = true,
}) {
const [expanded, setExpanded] = useState(defaultExpanded)
const [slotOpenId, setSlotOpenId] = useState(null)
const skills = profile?.skills || []
const maxShare = useMemo(
() => Math.max(...skills.map((s) => s.share_percent || 0), 1),
[skills]
)
if (loading) {
return (
<div className="card skill-profile skill-profile--loading">
<p className="skill-profile__status">Fähigkeiten-Profil wird berechnet…</p>
</div>
)
}
if (error) {
return (
<div className="card skill-profile skill-profile--error">
<p className="skill-profile__status">{error}</p>
</div>
)
}
const noData =
!profile ||
(profile.exercise_occurrence_count === 0 && profile.distinct_exercise_count === 0)
return (
<div className="card skill-profile">
<button
type="button"
className="skill-profile__toggle"
onClick={() => setExpanded((v) => !v)}
aria-expanded={expanded}
>
<span className="skill-profile__toggle-title">{title}</span>
{!noData && skills.length > 0 ? (
<span className="skill-profile__toggle-badge">
Top: {skills[0].skill_name} ({skills[0].share_percent}%)
</span>
) : null}
<span className="skill-profile__toggle-icon" aria-hidden="true">
{expanded ? '▾' : '▸'}
</span>
</button>
{expanded ? (
<div className="skill-profile__body">
<p className="form-sub skill-profile__hint">{hint}</p>
{noData ? (
<p className="skill-profile__empty">
Noch keine Übungen mit Fähigkeiten-Verknüpfung — lege Übungen im Ablauf an und verknüpfe
Fähigkeiten in der Übungsbearbeitung.
</p>
) : profile.exercises_with_skills_count === 0 ? (
<p className="skill-profile__empty">
{profile.distinct_exercise_count} Übung{profile.distinct_exercise_count === 1 ? '' : 'en'} im
Ablauf, aber keine Fähigkeiten an den Übungen hinterlegt.
</p>
) : (
<>
<div className="skill-profile__stats">
<span>
<strong>{profile.distinct_exercise_count}</strong> Übungen
</span>
<span>
<strong>{skills.length}</strong> Fähigkeiten
</span>
<span>
<strong>{profile.exercise_occurrence_count}</strong> Positionen
</span>
</div>
<ul className="skill-profile__list" aria-label="Fähigkeiten nach Gewicht">
{skills.slice(0, 12).map((sk) => (
<SkillBar key={sk.skill_id} skill={sk} maxShare={maxShare} />
))}
</ul>
{profile.by_category?.length > 1 ? (
<div className="skill-profile__categories">
<span className="skill-profile__categories-label">Nach Kategorie</span>
<div className="skill-profile__category-chips">
{profile.by_category.slice(0, 6).map((c) => (
<span key={c.category} className="skill-profile__category-chip">
{c.category} {c.share_percent}%
</span>
))}
</div>
</div>
) : null}
</>
)}
{slots && slots.length > 0 ? (
<div className="skill-profile__slots">
<span className="skill-profile__slots-label">Pro Session</span>
<ul className="skill-profile__slot-list">
{slots.map((sl) => {
const open = slotOpenId === sl.slot_id
const top = sl.profile?.skills?.[0]
return (
<li key={sl.slot_id} className="skill-profile__slot-item">
<button
type="button"
className="skill-profile__slot-btn"
onClick={() => setSlotOpenId(open ? null : sl.slot_id)}
aria-expanded={open}
>
<span>
{(sl.slot_title || '').trim() || `Session ${(sl.sort_order ?? 0) + 1}`}
</span>
{top ? (
<span className="skill-profile__slot-top">
{top.skill_name} {top.share_percent}%
</span>
) : (
<span className="skill-profile__slot-top skill-profile__slot-top--muted">
{sl.exercise_occurrence_count > 0 ? 'ohne Fähigkeiten' : 'kein Ablauf'}
</span>
)}
</button>
{open && sl.profile?.skills?.length > 0 ? (
<ul className="skill-profile__list skill-profile__list--nested">
{sl.profile.skills.slice(0, 6).map((sk) => (
<SkillBar
key={sk.skill_id}
skill={sk}
maxShare={Math.max(
...sl.profile.skills.map((x) => x.share_percent || 0),
1
)}
/>
))}
</ul>
) : null}
</li>
)
})}
</ul>
</div>
) : null}
</div>
) : null}
</div>
)
}