Refactor Skill Scoring Functions and Enhance Corpus Handling
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 38s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m17s

- Introduced new helper functions for managing artifact type corpus, improving code organization and readability.
- Updated the `compute_club_corpus_reference` function to utilize the new corpus handling methods, enhancing clarity and maintainability.
- Refactored skill profile functions to leverage the new corpus structure, ensuring consistent data retrieval across different artifact types.
- Improved the handling of visibility clauses for library content, streamlining database queries for skill profiles.
- Enhanced the batch skill profile summary function to aggregate reference data by artifact type, improving performance and accuracy.
This commit is contained in:
Lars committed 2026-05-21 10:17:22 +02:00
1 parent 34966b9e84
commit 2de4c0b7c9
13 files changed
+375 -180

No files matched your search

@@ -689,6 +689,7 @@ export default function ExerciseProgressionGraphPanel({
loading={skillProfileLoading}
error={skillProfileError}
defaultExpanded
artifactType="progression_graph"
/>
<div className="card" style={{ marginBottom: '12px' }}>
<h3 style={{ marginTop: 0, fontSize: '1rem' }}>Sequenz / Reihe anlegen</h3>
@@ -137,6 +137,7 @@ export default function FrameworkProgramListCard({
</div>
<SkillProfileCompact
summary={skillSummary}
artifactType="framework_program"
loading={skillSummaryLoading}
displayLimit={skillDisplayLimit}
highlightSkillIds={skillFilterIds}
@@ -291,10 +291,10 @@ export default function FrameworkProgramsFilterBlock({
{catalogSkills.length > 0 ? (
<div className="fw-import-catalog-block fw-import-catalog-block--skills">
<span className="form-label">Fähigkeiten (Vereinsvergleich)</span>
<span className="form-label">Fähigkeiten (Rahmenprogramme)</span>
<p className="form-sub" style={{ margin: '0 0 8px' }}>
Filtert nach Trainingsgewicht relativ zum stärksten Vereins-Programm je Fähigkeit — ohne
Punktewerte eingeben.
Filtert nach Trainingsgewicht relativ zum stärksten sichtbaren Rahmenprogramm je Fähigkeit — nur
unter Rahmenprogrammen, nicht gegen Module.
</p>
<div className="framework-catalog-checkgrid fw-import-skill-grid">
{catalogSkills.map((sk) => (
@@ -312,7 +312,7 @@ export default function FrameworkProgramsFilterBlock({
{(filters.skillIds || []).length > 0 ? (
<div className="fw-import-skill-options">
<div className="form-row" style={{ marginBottom: 8 }}>
<label className="form-label">Mindest-Anteil am Vereins-Maximum</label>
<label className="form-label">Mindest-Anteil am Rahmenprogramm-Maximum</label>
<select
className="form-input"
value={String(filters.skillMinClubPercent ?? 0)}
@@ -1,11 +1,17 @@
import React from 'react'
import { formatClubPercent, formatSkillWeight, kpiRowsFromSummary } from '../../utils/skillProfileListHelpers'
import {
formatClubPercent,
formatSkillWeight,
kpiRowsFromSummary,
peerPercentSuffix,
} from '../../utils/skillProfileListHelpers'
/**
* Kleine KPI-Kacheln: je Unterkategorie die Top-Fähigkeit (Listen/Karten).
*/
export default function SkillProfileCompact({
summary,
artifactType = 'training_module',
loading = false,
emptyText = 'Keine Fähigkeiten',
displayLimit = 24,
@@ -21,6 +27,7 @@ export default function SkillProfileCompact({
const rows = kpiRowsFromSummary(summary, { limit: displayLimit })
const highlight = new Set((highlightSkillIds || []).map(String))
const peerLabel = peerPercentSuffix(artifactType)
if (!rows.length) {
return summary ? <p className="form-sub skill-kpi-grid--empty">{emptyText}</p> : null
@@ -39,14 +46,14 @@ export default function SkillProfileCompact({
(highlighted ? ' skill-kpi-tile--highlight' : '') +
(isBest ? ' skill-kpi-tile--best' : '')
}
title={`${row.category_name}: ${row.skill_name} — Gewicht ${formatSkillWeight(row.weight ?? row.score)}, ${formatClubPercent(row.universal_percent)} vom Vereins-Maximum`}
title={`${row.category_name}: ${row.skill_name} — Gewicht ${formatSkillWeight(row.weight ?? row.score)}, ${formatClubPercent(row.universal_percent)} unter ${peerLabel}`}
>
<span className="skill-kpi-tile__cat">{row.category_name}</span>
<span className="skill-kpi-tile__name">{row.skill_name}</span>
<span className="skill-kpi-tile__score">{formatSkillWeight(row.weight ?? row.score)}</span>
<span className="skill-kpi-tile__pct">
{isBest ? '★ ' : ''}
{formatClubPercent(row.universal_percent)}
{formatClubPercent(row.universal_percent)} {peerLabel}
</span>
</li>
)
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react'
import api from '../../utils/api'
import { peerCorpusCountLabel } from '../../utils/skillProfileListHelpers'
import SkillProfilePanel from './SkillProfilePanel'
/**
@@ -45,6 +46,9 @@ export default function SkillProfileFullModal({
if (!open) return null
const peerCountLabel = peerCorpusCountLabel(artifactType)
const scale = data?.reference_scale
return (
<div className="skill-profile-modal" role="dialog" aria-modal="true" aria-labelledby="skill-profile-modal-title">
<button type="button" className="skill-profile-modal__backdrop" aria-label="Schließen" onClick={onClose} />
@@ -66,11 +70,13 @@ export default function SkillProfileFullModal({
displayMode="full"
embedded
defaultExpanded
artifactType={artifactType}
/>
{data?.reference_scale?.scope === 'club' && !loading ? (
{scale && !loading ? (
<p className="form-sub skill-profile-modal__scale">
Vergleichsbasis: {data.reference_scale.artifacts_scanned ?? 0} Vereins-Artefakte (
{data.reference_scale.skills_in_corpus ?? 0} Fähigkeiten mit Referenz).
Vergleichsbasis: {scale.artifacts_scanned ?? 0} sichtbare {peerCountLabel} (
{scale.skills_in_corpus ?? 0} Fähigkeiten mit Referenz).
{scale.description ? ` ${scale.description}` : null}
</p>
) : null}
</div>
@@ -1,4 +1,8 @@
import React, { useMemo, useState } from 'react'
import {
formatClubPercent,
peerPercentSuffix,
} from '../../utils/skillProfileListHelpers'
function skillWeight(skill) {
return Number(skill?.weight ?? skill?.score ?? 0)
@@ -10,12 +14,6 @@ function formatWeight(value) {
return n % 1 === 0 ? String(n) : n.toFixed(1)
}
function formatClubPercent(value) {
if (value == null || !Number.isFinite(Number(value))) return '—'
const n = Math.min(100, Number(value))
return n % 1 === 0 ? `${n}%` : `${n.toFixed(1)}%`
}
function barFillPercent(skill, maxWeight, hasReferenceScale) {
if (hasReferenceScale && skill?.universal_percent != null) {
return Math.min(100, Number(skill.universal_percent))
@@ -24,15 +22,15 @@ function barFillPercent(skill, maxWeight, hasReferenceScale) {
return maxWeight > 0 ? Math.min(100, (w / maxWeight) * 100) : 0
}
function metricLabel(skill, hasReferenceScale) {
function metricLabel(skill, hasReferenceScale, peerLabel) {
if (hasReferenceScale && skill?.universal_percent != null) {
const best = skill.is_club_best_for_skill ? ' ★' : ''
return `${formatClubPercent(skill.universal_percent)} Verein${best}`
return `${formatClubPercent(skill.universal_percent)} ${peerLabel}${best}`
}
return formatWeight(skillWeight(skill))
}
function SkillRow({ skill, maxWeight, hasReferenceScale }) {
function SkillRow({ skill, maxWeight, hasReferenceScale, peerLabel }) {
if (!skill) return null
const pct = barFillPercent(skill, maxWeight, hasReferenceScale)
return (
@@ -45,7 +43,7 @@ function SkillRow({ skill, maxWeight, hasReferenceScale }) {
{skill.skill_name}
</span>
<span className="skill-profile__pct" title="Trainingsgewicht (gewichtete Minuten)">
{metricLabel(skill, hasReferenceScale)}
{metricLabel(skill, hasReferenceScale, peerLabel)}
</span>
</div>
<div className="skill-profile__bar-track" aria-hidden="true">
@@ -57,11 +55,11 @@ function SkillRow({ skill, maxWeight, hasReferenceScale }) {
{skill.club_best ? (
<>
{' '}
· Vereins-Top: {skill.club_best.artifact_title || skill.club_best.artifact_id} (
· Top unter {peerLabel}: {skill.club_best.artifact_title || skill.club_best.artifact_id} (
{formatWeight(skill.club_best.weight)})
</>
) : skill.is_club_best_for_skill ? (
' · Stärkste Vereins-Nutzung'
' · Stärkster unter ' + peerLabel
) : null}
</span>
) : null}
@@ -69,12 +67,19 @@ function SkillRow({ skill, maxWeight, hasReferenceScale }) {
)
}
function CategoryTopSkill({ skill, maxWeight, hasReferenceScale }) {
function CategoryTopSkill({ skill, maxWeight, hasReferenceScale, peerLabel }) {
if (!skill) return null
return <SkillRow skill={skill} maxWeight={maxWeight} hasReferenceScale={hasReferenceScale} />
return (
<SkillRow
skill={skill}
maxWeight={maxWeight}
hasReferenceScale={hasReferenceScale}
peerLabel={peerLabel}
/>
)
}
function CategoryGroupedProfile({ profile, ariaLabel }) {
function CategoryGroupedProfile({ profile, ariaLabel, peerLabel }) {
const groups = profile?.by_main_category || []
const hasReferenceScale = Boolean(profile?.has_reference_scale)
const maxWeight = useMemo(() => {
@@ -104,6 +109,7 @@ function CategoryGroupedProfile({ profile, ariaLabel }) {
skill={cat.top_skill}
maxWeight={maxWeight}
hasReferenceScale={hasReferenceScale}
peerLabel={peerLabel}
/>
</div>
</li>
@@ -115,7 +121,7 @@ function CategoryGroupedProfile({ profile, ariaLabel }) {
)
}
function FullSkillsProfile({ profile, ariaLabel }) {
function FullSkillsProfile({ profile, ariaLabel, peerLabel }) {
const skills = profile?.skills || []
const hasReferenceScale = Boolean(profile?.has_reference_scale)
const maxWeight = useMemo(
@@ -133,6 +139,7 @@ function FullSkillsProfile({ profile, ariaLabel }) {
skill={sk}
maxWeight={maxWeight}
hasReferenceScale={hasReferenceScale}
peerLabel={peerLabel}
/>
))}
</ul>
@@ -166,14 +173,17 @@ export default function SkillProfilePanel({
defaultExpanded = true,
displayMode = 'summary',
embedded = false,
artifactType = 'framework_program',
}) {
const [expanded, setExpanded] = useState(defaultExpanded)
const [slotOpenId, setSlotOpenId] = useState(null)
const peerLabel = peerPercentSuffix(artifactType)
const defaultHint =
displayMode === 'full'
? 'Alle verknüpften Fähigkeiten nach Trainingsgewicht. Vergleich zum Vereins-Maximum je Fähigkeit (max. 100 %).'
: 'Trainingsgewicht aus Dauer, Häufigkeit, Intensität und Stufen-Spanne. Pro Kategorie die stärkste Fähigkeit; Balken = Anteil am Vereins-Maximum.'
? `Alle verknüpften Fähigkeiten nach Trainingsgewicht. Prozent = Anteil am stärksten sichtbaren Eintrag unter ${peerLabel} je Fähigkeit.`
: `Trainingsgewicht aus Dauer, Häufigkeit, Intensität und Stufen-Spanne. Prozent vergleicht nur unter ${peerLabel}, nicht mit anderen Planungs-Artefakttypen.`
const hintText = hint || defaultHint
const badge = useMemo(() => topCategoryBadge(profile), [profile])
@@ -237,9 +247,17 @@ export default function SkillProfilePanel({
</div>
{displayMode === 'full' ? (
<FullSkillsProfile profile={profile} ariaLabel="Alle Fähigkeiten nach Gewicht" />
<FullSkillsProfile
profile={profile}
ariaLabel="Alle Fähigkeiten nach Gewicht"
peerLabel={peerLabel}
/>
) : (
<CategoryGroupedProfile profile={profile} ariaLabel="Top-Fähigkeit je Kategorie" />
<CategoryGroupedProfile
profile={profile}
ariaLabel="Top-Fähigkeit je Kategorie"
peerLabel={peerLabel}
/>
)}
</>
)}
@@ -275,11 +293,13 @@ export default function SkillProfilePanel({
<FullSkillsProfile
profile={sl.profile}
ariaLabel={`Alle Fähigkeiten Session ${(sl.sort_order ?? 0) + 1}`}
peerLabel={peerLabel}
/>
) : (
<CategoryGroupedProfile
profile={sl.profile}
ariaLabel={`Fähigkeiten Session ${(sl.sort_order ?? 0) + 1}`}
peerLabel={peerLabel}
/>
)
) : null}