2026-05-22 21:52:18 +02:00
|
|
|
"""
|
2026-05-22 22:09:28 +02:00
|
|
|
POST /api/planning/exercise-suggest — planungsgebundene Übungssuche (Hybrid + Profil + optional LLM-Rerank).
|
2026-05-22 21:52:18 +02:00
|
|
|
"""
|
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
|
|
|
|
|
|
from db import get_db, get_cursor
|
|
|
|
|
from tenant_context import TenantContext, get_tenant_context
|
|
|
|
|
from planning_exercise_suggest import PlanningExerciseSuggestRequest, suggest_planning_exercises
|
2026-05-23 11:46:25 +02:00
|
|
|
from planning_exercise_path_builder import ProgressionPathSuggestRequest, suggest_progression_path
|
2026-06-06 21:10:52 +02:00
|
|
|
from account_lifecycle import assert_min_account_state
|
|
|
|
|
from capabilities import probe_capability
|
2026-06-06 21:00:42 +02:00
|
|
|
from club_features import probe_club_feature_access, resolve_club_id_for_probe
|
2026-05-22 21:52:18 +02:00
|
|
|
|
|
|
|
|
router = APIRouter(prefix="/api/planning", tags=["planning_exercise_suggest"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/exercise-suggest")
|
|
|
|
|
def post_planning_exercise_suggest(
|
|
|
|
|
body: PlanningExerciseSuggestRequest,
|
|
|
|
|
tenant: TenantContext = Depends(get_tenant_context),
|
|
|
|
|
):
|
2026-06-06 21:00:42 +02:00
|
|
|
if body.include_llm_intent or body.include_llm_rank:
|
2026-06-06 21:10:52 +02:00
|
|
|
assert_min_account_state(tenant, "active_member", endpoint="POST /planning/exercise-suggest")
|
|
|
|
|
probe_capability(
|
|
|
|
|
tenant,
|
|
|
|
|
"planning.ai.suggest",
|
|
|
|
|
action="planning_suggest",
|
|
|
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
|
|
|
endpoint="POST /planning/exercise-suggest",
|
|
|
|
|
)
|
2026-06-06 21:00:42 +02:00
|
|
|
probe_club_feature_access(
|
|
|
|
|
feature_id="ai_calls",
|
|
|
|
|
action="planning_suggest",
|
|
|
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
|
|
|
profile_id=tenant.profile_id,
|
|
|
|
|
endpoint="POST /planning/exercise-suggest",
|
|
|
|
|
)
|
2026-05-22 21:52:18 +02:00
|
|
|
with get_db() as conn:
|
|
|
|
|
cur = get_cursor(conn)
|
|
|
|
|
return suggest_planning_exercises(cur, tenant=tenant, body=body)
|
2026-05-23 11:46:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("/progression-path-suggest")
|
|
|
|
|
def post_progression_path_suggest(
|
|
|
|
|
body: ProgressionPathSuggestRequest,
|
|
|
|
|
tenant: TenantContext = Depends(get_tenant_context),
|
|
|
|
|
):
|
2026-06-06 21:00:42 +02:00
|
|
|
if (
|
|
|
|
|
body.include_llm_intent
|
|
|
|
|
or body.include_llm_path_qa
|
|
|
|
|
or body.include_ai_gap_fill
|
|
|
|
|
):
|
2026-06-06 21:10:52 +02:00
|
|
|
assert_min_account_state(
|
|
|
|
|
tenant, "active_member", endpoint="POST /planning/progression-path-suggest"
|
|
|
|
|
)
|
|
|
|
|
probe_capability(
|
|
|
|
|
tenant,
|
|
|
|
|
"planning.ai.progression_path",
|
|
|
|
|
action="progression_path_suggest",
|
|
|
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
|
|
|
endpoint="POST /planning/progression-path-suggest",
|
|
|
|
|
)
|
2026-06-06 21:00:42 +02:00
|
|
|
probe_club_feature_access(
|
|
|
|
|
feature_id="ai_calls",
|
|
|
|
|
action="progression_path_suggest",
|
|
|
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
|
|
|
profile_id=tenant.profile_id,
|
|
|
|
|
endpoint="POST /planning/progression-path-suggest",
|
|
|
|
|
)
|
2026-05-23 11:46:25 +02:00
|
|
|
with get_db() as conn:
|
|
|
|
|
cur = get_cursor(conn)
|
|
|
|
|
return suggest_progression_path(cur, tenant=tenant, body=body)
|