Enhance Exercise Progression Graph Functionality and Visibility Logic
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m16s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m16s
- Introduced new functions for handling exercise visibility in progression graphs, including `library_content_visibility_for_progression_graph_sql` to manage visibility based on graph context. - Added `_supplemental_exercise_ids_from_body` to extract exercise IDs from request bodies, improving data handling in path suggestions. - Implemented visibility promotion candidate retrieval in the API, allowing for the identification of private exercises that need visibility adjustments when promoting graph visibility. - Enhanced existing SQL queries and retrieval functions to incorporate new visibility logic, ensuring accurate exercise visibility based on user roles and graph settings. - Updated frontend components to support visibility promotion workflows, including user prompts for managing private exercises during graph visibility changes. - Added tests to validate new visibility logic and ensure robustness in exercise retrieval and promotion processes.
This commit is contained in:
1 parent
7203c871fc
commit
b464047c3a
7 files changed
+447
-11
No files matched your search
@@ -58,6 +58,52 @@ def _normalize_exercise_kind_filter(exercise_kind_any: Optional[List[str]]) -> L
|
||||
return out
|
||||
|
||||
|
||||
def fetch_exercise_rows_by_ids(
|
||||
cur,
|
||||
exercise_ids: Sequence[int],
|
||||
*,
|
||||
vis_sql: str,
|
||||
vis_params: Sequence[Any],
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Lädt konkrete Übungen nach, wenn sie im Graph/Slot verankert sind (Pin-Sicherheit)."""
|
||||
ids = sorted({int(x) for x in exercise_ids if int(x) > 0})
|
||||
if not ids:
|
||||
return []
|
||||
ph = ",".join(["%s"] * len(ids))
|
||||
sql = f"""
|
||||
SELECT e.id, e.title, e.summary, e.method_archetype,
|
||||
(
|
||||
SELECT fa.name FROM exercise_focus_areas efa
|
||||
JOIN focus_areas fa ON fa.id = efa.focus_area_id
|
||||
WHERE efa.exercise_id = e.id
|
||||
ORDER BY efa.is_primary DESC NULLS LAST, fa.name ASC
|
||||
LIMIT 1
|
||||
) AS primary_focus_name,
|
||||
0.0::float AS ft_rank
|
||||
FROM exercises e
|
||||
WHERE e.id IN ({ph})
|
||||
AND ({vis_sql})
|
||||
AND COALESCE(e.status, '') <> %s
|
||||
"""
|
||||
params: List[Any] = list(ids) + list(vis_params) + ["archived"]
|
||||
cur.execute(sql, params)
|
||||
return [dict(r) for r in cur.fetchall()]
|
||||
|
||||
|
||||
def merge_supplemental_exercise_rows(
|
||||
rows: Sequence[Dict[str, Any]],
|
||||
supplemental: Sequence[Dict[str, Any]],
|
||||
) -> List[Dict[str, Any]]:
|
||||
seen = {int(r["id"]) for r in rows if r.get("id") is not None}
|
||||
out = list(rows)
|
||||
for row in supplemental:
|
||||
rid = int(row["id"])
|
||||
if rid not in seen:
|
||||
seen.add(rid)
|
||||
out.append(dict(row))
|
||||
return out
|
||||
|
||||
|
||||
def fetch_all_visible_exercise_rows(
|
||||
cur,
|
||||
*,
|
||||
@@ -438,6 +484,7 @@ def run_multistage_planning_retrieval(
|
||||
intent: str,
|
||||
intent_weights: Mapping[str, float],
|
||||
pack: Mapping[str, Any],
|
||||
supplemental_exercise_ids: Optional[Sequence[int]] = None,
|
||||
) -> Tuple[List[Dict[str, Any]], Dict[int, Set[int]], bool]:
|
||||
"""Orchestriert S1b-0 → S1b-1 (Voll-Library-Ranking)."""
|
||||
rows = fetch_all_visible_exercise_rows(
|
||||
@@ -447,6 +494,14 @@ def run_multistage_planning_retrieval(
|
||||
query=pack.get("retrieval_query") or query,
|
||||
exercise_kind_any=exercise_kind_any,
|
||||
)
|
||||
if supplemental_exercise_ids:
|
||||
extra = fetch_exercise_rows_by_ids(
|
||||
cur,
|
||||
supplemental_exercise_ids,
|
||||
vis_sql=vis_sql,
|
||||
vis_params=vis_params,
|
||||
)
|
||||
rows = merge_supplemental_exercise_rows(rows, extra)
|
||||
hits, skills_by_ex = rank_visible_library_hits(
|
||||
cur,
|
||||
rows,
|
||||
@@ -482,8 +537,10 @@ def profile_preselect_rows(
|
||||
|
||||
__all__ = [
|
||||
"fetch_all_visible_exercise_rows",
|
||||
"fetch_exercise_rows_by_ids",
|
||||
"fetch_retrieval_candidate_rows",
|
||||
"hybrid_score_planning_hits",
|
||||
"merge_supplemental_exercise_rows",
|
||||
"profile_preselect_rows",
|
||||
"rank_visible_library_hits",
|
||||
"run_multistage_planning_retrieval",
|
||||
|
||||
Reference in new issue
Block a user