diff --git a/README.md b/README.md index 7e9280b..8e67d57 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,16 @@ wodify list date 2026-07-25 ``` ``` -TIME COACH BOOKED CLASS DUR ID ------ ----------- ------ ----------------------- ----- --------- -07:00 Robin Vance 10/10 CrossFit: 7:00 AM 60min 192001199 -10:00 Pat Doyle 12/12 CrossFit Burn: 10:00 AM 60min 190918189 + TIME COACH BOOKED CLASS DUR YOU ID +- ----- ----------- ------ ----------------------- ----- --------- --------- + 07:00 Robin Vance 10/10 CrossFit: 7:00 AM 60min - 192001199 +» 10:00 Pat Doyle 12/12 CrossFit Burn: 10:00 AM 60min signed in 190918189 ``` +Your own classes are marked `»` with your status in the `YOU` column — `signed in` for +one you attended, `reserved` for one still upcoming. This costs no extra request: the +schedule response already reports the account's relationship to each class. + (Names above are illustrative — the tool prints whatever your gym returns.) Then feed an ID back in for the workout and the named attendee list: diff --git a/src/wodify/render.py b/src/wodify/render.py index b384be4..3f59145 100644 --- a/src/wodify/render.py +++ b/src/wodify/render.py @@ -147,17 +147,23 @@ def day_table(rows: list[dict[str, Any]], date: str) -> str: return (f"No classes found for {date}. Either nothing ran that day, or the " "programs are ones your account cannot see.") - header = ["TIME", "COACH", "BOOKED", "CLASS", "DUR", "ID"] + # The schedule reports the account's own relationship to each class in + # `Status` ("Signed In", "Reserved", ...), so the caller's classes can be + # highlighted without any extra request. + header = ["", "TIME", "COACH", "BOOKED", "CLASS", "DUR", "YOU", "ID"] table: list[list[str]] = [] for r in rows: mins = duration_minutes(r.get("start", ""), r.get("end") or r.get("finish") or "") booked, limit = r.get("booked"), r.get("limit") or r.get("class_limit") + status = str(r.get("status") or "").strip() table.append([ + "»" if status else "", _hhmm(r.get("start", "")), str(r.get("coach") or "-"), f"{booked}/{limit}" if booked is not None and limit else "-", str(r.get("name") or "-"), f"{mins}min" if mins else "-", + status.lower() if status else "-", str(r.get("class_id") or "-"), ]) @@ -464,6 +470,9 @@ def classes(data: Any) -> str: line += f" coach={r['coach']}" if r["class_id"]: line += f" class_id={r['class_id']}" + status = str(r.get("status") or "").strip() + if status: + line += f" «you: {status.lower()}»" lines.append(line) wod = workout(data) diff --git a/tests/test_schedule.py b/tests/test_schedule.py index bf1c79d..4796025 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -84,3 +84,42 @@ def test_classes_render_includes_capacity_coach_and_id(): assert "coach=Pat Doyle" in out assert "class_id=190917816" in out assert out.count("\n- ") + 1 == 3, "all three classes should be listed" + + +# --- own-reservation highlighting -------------------------------------------- +# The schedule row's Status field carries the account's relationship to the +# class ("Signed In", "Reserved", "" for none). Verified live 2026-07-25. + +def _day_with_status(): + day = {"Response": {"ResponseClassList": {"Class": {"List": [ + _row("1", "CrossFit: 12:00 PM", "12:00:00", "133059", 10, "Chris Nolan"), + _row("2", "CrossFit: 5:30 PM", "17:30:00", "133059", 9, "Pat Doyle"), + ]}}}} + day["Response"]["ResponseClassList"]["Class"]["List"][1]["Status"] = "Signed In" + return day + + +def test_class_rows_carry_own_status(): + rows = render.class_rows(_day_with_status()) + assert rows[0]["status"] == "" + assert rows[1]["status"] == "Signed In" + + +def test_day_table_marks_own_class(): + out = render.day_table(render.class_rows(_day_with_status()), "2026-07-24") + marked = [l for l in out.splitlines() if l.startswith("»")] + assert len(marked) == 1 + assert "CrossFit: 5:30 PM" in marked[0] and "signed in" in marked[0] + + +def test_day_table_unrelated_class_not_marked(): + out = render.day_table(render.class_rows(_day_with_status()), "2026-07-24") + noon = next(l for l in out.splitlines() if "12:00 PM" in l) + assert not noon.startswith("»") + assert "signed in" not in noon + + +def test_classes_renderer_marks_own_class(): + out = render.classes(_day_with_status()) + assert "«you: signed in»" in out + assert out.count("«you:") == 1