Update Skill Scoring Specification and Implementation to v1.2
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 38s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m27s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 38s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m27s
- Enhanced the skill scoring system with category grouping and a universal scale for improved comparability across programs. - Introduced new calculations for artifact share percentage and universal percent, allowing for a more nuanced understanding of skill contributions. - Updated the API to reflect changes in the skill profile structure, including main category and top skill details. - Improved frontend components to display skills by main category, enhancing user experience in skill discovery and profile visualization. - Adjusted tests to validate the new scoring logic and ensure accurate representation of skills and their weights.
This commit is contained in:
1 parent
8f8bdf6d8b
commit
5200895a73
8 files changed
+604
-139
No files matched your search
@@ -17,6 +17,7 @@ from skill_scoring import (
|
||||
collect_module_exercise_occurrences,
|
||||
collect_progression_graph_exercise_occurrences,
|
||||
collect_unit_exercise_occurrences,
|
||||
compute_corpus_skill_max_weights,
|
||||
compute_skill_profile,
|
||||
match_score_for_skill_ids,
|
||||
profile_for_occurrences,
|
||||
@@ -69,6 +70,13 @@ def framework_program_skill_profile(
|
||||
)
|
||||
slots_raw = [r2d(r) for r in cur.fetchall()]
|
||||
|
||||
ref_max = compute_corpus_skill_max_weights(
|
||||
cur,
|
||||
profile_id=profile_id,
|
||||
role=role,
|
||||
effective_club_id=tenant.effective_club_id,
|
||||
)
|
||||
|
||||
all_occurrences: List[ExerciseOccurrence] = []
|
||||
slot_profiles: List[Dict[str, Any]] = []
|
||||
|
||||
@@ -89,7 +97,11 @@ def framework_program_skill_profile(
|
||||
all_occurrences.extend(slot_occ)
|
||||
else:
|
||||
slot_occ = []
|
||||
slot_profile = profile_for_occurrences(cur, slot_occ) if slot_occ else _empty_profile()
|
||||
slot_profile = (
|
||||
profile_for_occurrences(cur, slot_occ, reference_max_by_skill=ref_max)
|
||||
if slot_occ
|
||||
else _empty_profile()
|
||||
)
|
||||
slot_profiles.append(
|
||||
{
|
||||
"slot_id": slot["id"],
|
||||
@@ -101,12 +113,20 @@ def framework_program_skill_profile(
|
||||
}
|
||||
)
|
||||
|
||||
overall = profile_for_occurrences(cur, all_occurrences) if all_occurrences else _empty_profile()
|
||||
overall = (
|
||||
profile_for_occurrences(cur, all_occurrences, reference_max_by_skill=ref_max)
|
||||
if all_occurrences
|
||||
else _empty_profile()
|
||||
)
|
||||
|
||||
return {
|
||||
"artifact_type": "framework_program",
|
||||
"artifact_id": framework_id,
|
||||
"artifact_title": row.get("title"),
|
||||
"reference_scale": {
|
||||
"skills_in_corpus": len(ref_max),
|
||||
"description": "universal_percent = Anteil am höchsten Trainingsgewicht dieser Fähigkeit in der sichtbaren Bibliothek",
|
||||
},
|
||||
"overall": overall,
|
||||
"slots": slot_profiles,
|
||||
}
|
||||
@@ -122,12 +142,25 @@ def training_module_skill_profile(
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
row = _module_access(cur, module_id, profile_id, role)
|
||||
ref_max = compute_corpus_skill_max_weights(
|
||||
cur,
|
||||
profile_id=profile_id,
|
||||
role=role,
|
||||
effective_club_id=tenant.effective_club_id,
|
||||
)
|
||||
occurrences = collect_module_exercise_occurrences(cur, module_id)
|
||||
overall = profile_for_occurrences(cur, occurrences) if occurrences else _empty_profile()
|
||||
overall = (
|
||||
profile_for_occurrences(cur, occurrences, reference_max_by_skill=ref_max)
|
||||
if occurrences
|
||||
else _empty_profile()
|
||||
)
|
||||
return {
|
||||
"artifact_type": "training_module",
|
||||
"artifact_id": module_id,
|
||||
"artifact_title": row.get("title"),
|
||||
"reference_scale": {
|
||||
"skills_in_corpus": len(ref_max),
|
||||
},
|
||||
"overall": overall,
|
||||
}
|
||||
|
||||
@@ -142,22 +175,34 @@ def progression_graph_skill_profile(
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
row = _require_graph_read(cur, graph_id, profile_id, role)
|
||||
ref_max = compute_corpus_skill_max_weights(
|
||||
cur,
|
||||
profile_id=profile_id,
|
||||
role=role,
|
||||
effective_club_id=tenant.effective_club_id,
|
||||
)
|
||||
occurrences = collect_progression_graph_exercise_occurrences(cur, graph_id)
|
||||
overall = profile_for_occurrences(
|
||||
cur, occurrences, default_item_minutes=GRAPH_DEFAULT_ITEM_MINUTES
|
||||
) if occurrences else _empty_profile()
|
||||
overall = (
|
||||
profile_for_occurrences(
|
||||
cur,
|
||||
occurrences,
|
||||
default_item_minutes=GRAPH_DEFAULT_ITEM_MINUTES,
|
||||
reference_max_by_skill=ref_max,
|
||||
)
|
||||
if occurrences
|
||||
else _empty_profile()
|
||||
)
|
||||
return {
|
||||
"artifact_type": "progression_graph",
|
||||
"artifact_id": graph_id,
|
||||
"artifact_title": row.get("name"),
|
||||
"reference_scale": {
|
||||
"skills_in_corpus": len(ref_max),
|
||||
},
|
||||
"overall": overall,
|
||||
}
|
||||
|
||||
|
||||
def _empty_profile() -> Dict[str, Any]:
|
||||
return compute_skill_profile([], {})
|
||||
|
||||
|
||||
@router.get("/skill-discovery/suggestions")
|
||||
def skill_discovery_suggestions(
|
||||
skill_ids: str = Query(..., description="Komma-getrennte skill-IDs"),
|
||||
@@ -232,11 +277,8 @@ def skill_discovery_suggestions(
|
||||
"path": f"/planning/framework-programs/{fid}",
|
||||
"match": match,
|
||||
"skill_profile_summary": {
|
||||
"total_weight": prof.get("total_weight"),
|
||||
"top_skills": [
|
||||
{"skill_id": s["skill_id"], "skill_name": s["skill_name"], "share_percent": s["share_percent"]}
|
||||
for s in (prof.get("skills") or [])[:5]
|
||||
],
|
||||
"total_score": prof.get("total_score"),
|
||||
"top_by_category": _top_categories_summary(prof),
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -279,11 +321,8 @@ def skill_discovery_suggestions(
|
||||
"path": f"/planning/training-modules/{mid}",
|
||||
"match": match,
|
||||
"skill_profile_summary": {
|
||||
"total_weight": prof.get("total_weight"),
|
||||
"top_skills": [
|
||||
{"skill_id": s["skill_id"], "skill_name": s["skill_name"], "share_percent": s["share_percent"]}
|
||||
for s in (prof.get("skills") or [])[:5]
|
||||
],
|
||||
"total_score": prof.get("total_score"),
|
||||
"top_by_category": _top_categories_summary(prof),
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -328,20 +367,14 @@ def skill_discovery_suggestions(
|
||||
"path": None,
|
||||
"match": match,
|
||||
"skill_profile_summary": {
|
||||
"total_weight": prof.get("total_weight"),
|
||||
"top_skills": [
|
||||
{"skill_id": s["skill_id"], "skill_name": s["skill_name"], "share_percent": s["share_percent"]}
|
||||
for s in (prof.get("skills") or [])[:5]
|
||||
],
|
||||
"total_score": prof.get("total_score"),
|
||||
"top_by_category": _top_categories_summary(prof),
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
results.sort(
|
||||
key=lambda x: (
|
||||
-float(x.get("match", {}).get("match_weight") or 0),
|
||||
-(float(x.get("match", {}).get("match_percent") or 0)),
|
||||
)
|
||||
key=lambda x: -float(x.get("match", {}).get("match_score") or x.get("match", {}).get("match_weight") or 0),
|
||||
)
|
||||
return {
|
||||
"skill_ids": wanted,
|
||||
@@ -350,5 +383,27 @@ def skill_discovery_suggestions(
|
||||
}
|
||||
|
||||
|
||||
def _top_categories_summary(profile: Dict[str, Any], limit: int = 6) -> List[Dict[str, Any]]:
|
||||
"""Kurzliste Top-Fähigkeit je Unterkategorie für Discovery-Treffer."""
|
||||
out: List[Dict[str, Any]] = []
|
||||
for mc in profile.get("by_main_category") or []:
|
||||
for cat in mc.get("categories") or []:
|
||||
top = cat.get("top_skill")
|
||||
if not top:
|
||||
continue
|
||||
out.append(
|
||||
{
|
||||
"main_category_name": mc.get("main_category_name"),
|
||||
"category_name": cat.get("category_name"),
|
||||
"skill_id": top.get("skill_id"),
|
||||
"skill_name": top.get("skill_name"),
|
||||
"score": top.get("score") or top.get("weight"),
|
||||
}
|
||||
)
|
||||
if len(out) >= limit:
|
||||
return out
|
||||
return out
|
||||
|
||||
|
||||
def _empty_profile() -> Dict[str, Any]:
|
||||
return compute_skill_profile([], {})
|
||||
Reference in new issue
Block a user