Implement Phase C2 Enhancements for Exercise Suggestions
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 18s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m14s
Test Suite / pytest-backend (pull_request) Successful in 38s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m13s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 18s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m14s
Test Suite / pytest-backend (pull_request) Successful in 38s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m13s
- Incremented version to 0.8.184, reflecting the implementation of Phase C2 features. - Added support for displaying variant lists and suggested variant names in exercise suggestions. - Enhanced the ExercisePickerModal to allow selection of exercise variants and improved handling of variant IDs. - Updated backend logic to enrich planning hits with variant metadata, ensuring accurate exercise variant selection. - Documented changes in the changelog to highlight the new capabilities in planning AI functionality.
This commit is contained in:
1 parent
b2157d8a40
commit
a34e748be5
10 files changed
+280
-27
No files matched your search
@@ -211,6 +211,79 @@ def _resolve_anchor_variant_id(
|
||||
return None
|
||||
|
||||
|
||||
def _enrich_planning_hits_with_variant_meta(
|
||||
cur,
|
||||
hits: Sequence[Dict[str, Any]],
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Variantennamen und -listen für Treffer mit suggested_variant_id (Phase C2)."""
|
||||
if not hits:
|
||||
return []
|
||||
variant_ids: Set[int] = set()
|
||||
exercise_ids: Set[int] = set()
|
||||
for h in hits:
|
||||
exercise_ids.add(int(h["id"]))
|
||||
raw = h.get("suggested_variant_id")
|
||||
if raw is not None:
|
||||
try:
|
||||
vid = int(raw)
|
||||
except (TypeError, ValueError):
|
||||
vid = 0
|
||||
if vid > 0:
|
||||
variant_ids.add(vid)
|
||||
|
||||
names_by_variant: Dict[int, str] = {}
|
||||
if variant_ids:
|
||||
ph = ",".join(["%s"] * len(variant_ids))
|
||||
cur.execute(
|
||||
f"SELECT id, variant_name FROM exercise_variants WHERE id IN ({ph})",
|
||||
list(variant_ids),
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
n = (row.get("variant_name") or "").strip()
|
||||
if n:
|
||||
names_by_variant[int(row["id"])] = n
|
||||
|
||||
variants_by_exercise: Dict[int, List[Dict[str, Any]]] = {}
|
||||
if exercise_ids:
|
||||
ph = ",".join(["%s"] * len(exercise_ids))
|
||||
cur.execute(
|
||||
f"""
|
||||
SELECT exercise_id, id, variant_name, sequence_order
|
||||
FROM exercise_variants
|
||||
WHERE exercise_id IN ({ph})
|
||||
ORDER BY exercise_id, sequence_order NULLS LAST, id
|
||||
""",
|
||||
list(exercise_ids),
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
eid = int(row["exercise_id"])
|
||||
variants_by_exercise.setdefault(eid, []).append(
|
||||
{
|
||||
"id": int(row["id"]),
|
||||
"variant_name": (row.get("variant_name") or "").strip() or None,
|
||||
"sequence_order": row.get("sequence_order"),
|
||||
}
|
||||
)
|
||||
|
||||
out: List[Dict[str, Any]] = []
|
||||
for h in hits:
|
||||
item = dict(h)
|
||||
eid = int(item["id"])
|
||||
vars_for_ex = variants_by_exercise.get(eid) or []
|
||||
if vars_for_ex:
|
||||
item["variants"] = vars_for_ex
|
||||
raw_vid = item.get("suggested_variant_id")
|
||||
if raw_vid is not None:
|
||||
try:
|
||||
vid = int(raw_vid)
|
||||
except (TypeError, ValueError):
|
||||
vid = 0
|
||||
if vid > 0:
|
||||
item["suggested_variant_name"] = names_by_variant.get(vid)
|
||||
out.append(item)
|
||||
return out
|
||||
|
||||
|
||||
def _finalize_progression_context(
|
||||
cur,
|
||||
tenant: TenantContext,
|
||||
@@ -728,6 +801,7 @@ def suggest_planning_exercises(
|
||||
hits = hits[: int(body.limit)]
|
||||
|
||||
hits = hits[: int(body.limit)]
|
||||
hits = _enrich_planning_hits_with_variant_meta(cur, hits)
|
||||
|
||||
context_summary = {
|
||||
"unit_title": pack.get("unit_title"),
|
||||
|
||||
Reference in new issue
Block a user