feat: mark the account own classes in list date
`list date` showed the day but nothing personal, so spotting your own class meant cross-referencing `bookings` by hand. No extra request is needed: each schedule row already carries the account relationship in `Status` -- "Signed In" for a class attended, "Reserved" for one upcoming, empty otherwise (verified live against both cases). class_rows already parsed it; it was simply never displayed. Rows now get a `»` marker and a YOU column with the lowercased status. The compact `classes` renderer gains an equivalent `«you: ...»` suffix. 138 tests, no network required. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
8ab4ad4b17
commit
ae3c39b384
3 files changed
+57
-5
No files matched your search
+10
-1
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user