feat(version): bump to 0.8.110 and enhance combination exercise features
- Updated app version to 0.8.110, reflecting recent improvements in combination exercise handling. - Introduced `load_combination_slots_for_exercise` function to streamline fetching combination slots for exercises. - Enhanced `TrainingPlanningPage` and `ExercisePeekModal` to utilize the new combination slots functionality, improving user experience. - Updated changelog to document the latest changes and feature enhancements. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
5dc93d9a8c
commit
a8942a9e4e
10 files changed
+475
-84
No files matched your search
@@ -974,6 +974,43 @@ def assert_exercise_not_combination(cur, exercise_id: int) -> None:
|
||||
)
|
||||
|
||||
|
||||
def load_combination_slots_for_exercise(cur, exercise_id: int) -> List[dict]:
|
||||
"""Stationsliste einer Kombinationsübung (gleiches Format wie GET /api/exercises/:id)."""
|
||||
cur.execute(
|
||||
"""SELECT id, slot_index, title FROM combination_exercise_slots
|
||||
WHERE exercise_id = %s ORDER BY slot_index ASC, id ASC""",
|
||||
(exercise_id,),
|
||||
)
|
||||
slot_rows = [r2d(r) for r in cur.fetchall()]
|
||||
slots_out: List[dict] = []
|
||||
for sr in slot_rows:
|
||||
slot_pk = sr["id"]
|
||||
cur.execute(
|
||||
"""SELECT candidate_exercise_id FROM combination_slot_candidates
|
||||
WHERE slot_id = %s ORDER BY sort_order ASC, id ASC""",
|
||||
(slot_pk,),
|
||||
)
|
||||
crows = cur.fetchall()
|
||||
cids = [int(r2d(c)["candidate_exercise_id"]) for c in crows]
|
||||
cand_meta: Dict[int, Optional[str]] = {}
|
||||
if cids:
|
||||
ph = ",".join(["%s"] * len(cids))
|
||||
cur.execute(
|
||||
f"SELECT id, title FROM exercises WHERE id IN ({ph})",
|
||||
tuple(cids),
|
||||
)
|
||||
cand_meta = {int(r2d(x)["id"]): r2d(x).get("title") for x in cur.fetchall()}
|
||||
slots_out.append(
|
||||
{
|
||||
"slot_index": sr["slot_index"],
|
||||
"title": sr.get("title"),
|
||||
"candidate_exercise_ids": cids,
|
||||
"candidates": [{"exercise_id": cid, "title": cand_meta.get(cid)} for cid in cids],
|
||||
}
|
||||
)
|
||||
return slots_out
|
||||
|
||||
|
||||
def enrich_exercise_detail(exercise_id: int, cur) -> dict:
|
||||
"""
|
||||
Lädt alle M:N Relations für eine Übung und gibt ein vollständiges
|
||||
@@ -1102,41 +1139,7 @@ def enrich_exercise_detail(exercise_id: int, cur) -> dict:
|
||||
|
||||
exercise["combination_slots"] = []
|
||||
if exercise["exercise_kind"] == "combination":
|
||||
cur.execute(
|
||||
"""SELECT id, slot_index, title FROM combination_exercise_slots
|
||||
WHERE exercise_id = %s ORDER BY slot_index ASC, id ASC""",
|
||||
(exercise_id,),
|
||||
)
|
||||
slot_rows = [r2d(r) for r in cur.fetchall()]
|
||||
slots_out: List[dict] = []
|
||||
for sr in slot_rows:
|
||||
slot_pk = sr["id"]
|
||||
cur.execute(
|
||||
"""SELECT candidate_exercise_id FROM combination_slot_candidates
|
||||
WHERE slot_id = %s ORDER BY sort_order ASC, id ASC""",
|
||||
(slot_pk,),
|
||||
)
|
||||
crows = cur.fetchall()
|
||||
cids = [int(r2d(c)["candidate_exercise_id"]) for c in crows]
|
||||
cand_meta: Dict[int, Optional[str]] = {}
|
||||
if cids:
|
||||
ph = ",".join(["%s"] * len(cids))
|
||||
cur.execute(
|
||||
f"SELECT id, title FROM exercises WHERE id IN ({ph})",
|
||||
tuple(cids),
|
||||
)
|
||||
cand_meta = {int(r2d(x)["id"]): r2d(x).get("title") for x in cur.fetchall()}
|
||||
slots_out.append(
|
||||
{
|
||||
"slot_index": sr["slot_index"],
|
||||
"title": sr.get("title"),
|
||||
"candidate_exercise_ids": cids,
|
||||
"candidates": [
|
||||
{"exercise_id": cid, "title": cand_meta.get(cid)} for cid in cids
|
||||
],
|
||||
}
|
||||
)
|
||||
exercise["combination_slots"] = slots_out
|
||||
exercise["combination_slots"] = load_combination_slots_for_exercise(cur, exercise_id)
|
||||
|
||||
return exercise
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ from club_tenancy import (
|
||||
)
|
||||
from routers.training_modules import load_training_module_for_apply
|
||||
|
||||
from routers.exercises import load_combination_slots_for_exercise
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["training_planning"])
|
||||
|
||||
|
||||
@@ -493,6 +495,14 @@ def _fetch_sections(cur, unit_id: int) -> List[Dict[str, Any]]:
|
||||
it["catalog_method_profile"] = {}
|
||||
else:
|
||||
it["catalog_method_profile"] = dict(cmp_raw)
|
||||
ek = str(it.get("exercise_kind") or "simple").strip().lower()
|
||||
if ek == "combination" and it.get("exercise_id"):
|
||||
try:
|
||||
it["combination_slots"] = load_combination_slots_for_exercise(cur, int(it["exercise_id"]))
|
||||
except (TypeError, ValueError):
|
||||
it["combination_slots"] = []
|
||||
else:
|
||||
it["combination_slots"] = []
|
||||
secs.append(sec)
|
||||
return secs
|
||||
|
||||
|
||||
Reference in new issue
Block a user