Update Skill Profile Summary and Frontend Components
Deploy Development / deploy (push) Successful in 43s
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 1m13s

- Modified the `compact_profile_summary` function to allow for dynamic skill and category limits, enhancing flexibility in profile data retrieval.
- Updated frontend components to display skill weights and scores more effectively, improving user interaction with skill metrics.
- Adjusted CSS styles for skill KPI tiles to better differentiate between score and percentage displays, ensuring a clearer visual representation.
- Refactored utility functions to streamline skill summary handling, enhancing overall code maintainability and performance.
This commit is contained in:
Lars committed 2026-05-21 09:42:13 +02:00
1 parent 9a0cf7f823
commit 34966b9e84
7 files changed
+165 -39

No files matched your search

+111 -11
View File
@@ -14,12 +14,17 @@ from tenant_context import TenantContext, get_tenant_context, library_content_vi
from skill_scoring import (
GRAPH_DEFAULT_ITEM_MINUTES,
ExerciseOccurrence,
batch_compute_profiles,
batch_framework_occurrences_by_id,
batch_module_occurrences_by_id,
collect_module_exercise_occurrences,
collect_progression_graph_exercise_occurrences,
collect_unit_exercise_occurrences,
compact_profile_summary,
compute_club_corpus_reference,
compute_corpus_skill_max_weights,
compute_skill_profile,
fetch_exercise_skills_bulk,
match_score_for_skill_ids,
profile_for_occurrences,
reference_scale_meta,
@@ -239,33 +244,31 @@ def batch_skill_profile_summaries(
include_artifact_summaries=True,
)
ref_by_skill = corpus["ref_by_skill"]
all_summaries = corpus.get("artifact_summaries") or {}
allowed_fp: List[int] = []
if fp_ids:
allowed_fp = []
for fid in fp_ids:
try:
_framework_access(cur, fid, profile_id, role)
allowed_fp.append(fid)
except HTTPException:
pass
for fid in allowed_fp:
key = f"framework_program:{fid}"
if key in all_summaries:
summaries[key] = all_summaries[key]
allowed_mod: List[int] = []
if mod_ids:
allowed_mod = []
for mid in mod_ids:
try:
_module_access(cur, mid, profile_id, role)
allowed_mod.append(mid)
except HTTPException:
pass
for mid in allowed_mod:
key = f"training_module:{mid}"
if key in all_summaries:
summaries[key] = all_summaries[key]
summaries = _merge_batch_summaries(
cur,
corpus=corpus,
allowed_fp=allowed_fp,
allowed_mod=allowed_mod,
)
skill_ids_seen: set[int] = set()
for summary in summaries.values():
@@ -551,3 +554,100 @@ def _enrich_profile_club_best(
def _empty_profile() -> Dict[str, Any]:
return compute_skill_profile([], {})
def _summarize_framework_program(
cur,
framework_id: int,
ref_max: Dict[int, float],
ref_by_skill: Dict[int, Dict[str, Any]],
) -> Dict[str, Any]:
cur.execute(
"""
SELECT tu.id
FROM training_framework_slots s
INNER JOIN training_units tu ON tu.framework_slot_id = s.id
WHERE s.framework_program_id = %s
""",
(int(framework_id),),
)
occ: List[ExerciseOccurrence] = []
for u in cur.fetchall():
occ.extend(collect_unit_exercise_occurrences(cur, int(u["id"])))
prof = (
profile_for_occurrences(cur, occ, reference_max_by_skill=ref_max)
if occ
else _empty_profile()
)
_enrich_profile_club_best(prof, ref_by_skill, "framework_program", int(framework_id))
return compact_profile_summary(prof, ref_by_skill)
def _summarize_training_module(
cur,
module_id: int,
ref_max: Dict[int, float],
ref_by_skill: Dict[int, Dict[str, Any]],
) -> Dict[str, Any]:
occ = collect_module_exercise_occurrences(cur, int(module_id))
prof = (
profile_for_occurrences(cur, occ, reference_max_by_skill=ref_max)
if occ
else _empty_profile()
)
_enrich_profile_club_best(prof, ref_by_skill, "training_module", int(module_id))
return compact_profile_summary(prof, ref_by_skill)
def _merge_batch_summaries(
cur,
*,
corpus: Dict[str, Any],
allowed_fp: List[int],
allowed_mod: List[int],
) -> Dict[str, Dict[str, Any]]:
"""Summaries für angeforderte IDs — auch official/private (nicht nur Vereins-Corpus-Cache)."""
ref_max = corpus["max_by_skill"]
ref_by_skill = corpus["ref_by_skill"]
cached = corpus.get("artifact_summaries") or {}
out: Dict[str, Dict[str, Any]] = {}
missing_fp = [fid for fid in allowed_fp if f"framework_program:{fid}" not in cached]
if missing_fp:
occ_map = batch_framework_occurrences_by_id(cur, missing_fp)
all_eids = {o.exercise_id for occs in occ_map.values() for o in occs}
skills_map = fetch_exercise_skills_bulk(cur, all_eids) if all_eids else {}
profiles = batch_compute_profiles(occ_map, skills_map, reference_max_by_skill=ref_max)
for fid in missing_fp:
key = f"framework_program:{fid}"
prof = profiles.get(fid) or _empty_profile()
_enrich_profile_club_best(prof, ref_by_skill, "framework_program", fid)
out[key] = compact_profile_summary(prof, ref_by_skill)
missing_mod = [mid for mid in allowed_mod if f"training_module:{mid}" not in cached]
if missing_mod:
occ_map = batch_module_occurrences_by_id(cur, missing_mod)
all_eids = {o.exercise_id for occs in occ_map.values() for o in occs}
skills_map = fetch_exercise_skills_bulk(cur, all_eids) if all_eids else {}
profiles = batch_compute_profiles(occ_map, skills_map, reference_max_by_skill=ref_max)
for mid in missing_mod:
key = f"training_module:{mid}"
prof = profiles.get(mid) or _empty_profile()
_enrich_profile_club_best(prof, ref_by_skill, "training_module", mid)
out[key] = compact_profile_summary(prof, ref_by_skill)
for fid in allowed_fp:
key = f"framework_program:{fid}"
if key in cached:
out[key] = cached[key]
elif key not in out:
out[key] = _summarize_framework_program(cur, fid, ref_max, ref_by_skill)
for mid in allowed_mod:
key = f"training_module:{mid}"
if key in cached:
out[key] = cached[key]
elif key not in out:
out[key] = _summarize_training_module(cur, mid, ref_max, ref_by_skill)
return out