schizo v3 working excused detection
This commit is contained in:
parent
5b4aee13e7
commit
a423d0a645
1 changed files with 24 additions and 7 deletions
31
main.py
31
main.py
|
|
@ -166,10 +166,28 @@ def _absence_sort_key(ab: dict):
|
||||||
return (0, 0)
|
return (0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_excused(ab: dict) -> bool | None:
|
||||||
|
"""
|
||||||
|
Return True if excused, False if unexcused, None if unknown.
|
||||||
|
isExcused is a direct bool field on the absence object.
|
||||||
|
"""
|
||||||
|
# Top-level isExcused is the authoritative field
|
||||||
|
if "isExcused" in ab:
|
||||||
|
val = ab["isExcused"]
|
||||||
|
if isinstance(val, bool):
|
||||||
|
return val
|
||||||
|
# Fall back to excuseStatus text
|
||||||
|
status_text = (ab.get("excuseStatus") or "").lower()
|
||||||
|
if "nicht" in status_text:
|
||||||
|
return False
|
||||||
|
if status_text:
|
||||||
|
return True
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _is_unexcused(ab: dict) -> bool:
|
def _is_unexcused(ab: dict) -> bool:
|
||||||
excused = ab.get("isExcused") or ab.get("excused") or ab.get("excuse")
|
result = _resolve_excused(ab)
|
||||||
print(f"Debug: Absence {ab.get('id', '?')} excuse status: {excused}")
|
return result is False or result is None # unknown treated as unexcused
|
||||||
return excused
|
|
||||||
|
|
||||||
|
|
||||||
def filter_absences(absences: list[dict], unexcused_only: bool) -> list[dict]:
|
def filter_absences(absences: list[dict], unexcused_only: bool) -> list[dict]:
|
||||||
|
|
@ -192,11 +210,10 @@ def _parse_dt(date_int, time_int) -> str:
|
||||||
|
|
||||||
|
|
||||||
def _excuse_label(ab: dict) -> str:
|
def _excuse_label(ab: dict) -> str:
|
||||||
excused = ab.get("isExcused") or ab.get("excused") or ab.get("excuse")
|
result = _resolve_excused(ab)
|
||||||
if excused is True or excused == 1:
|
if result is True:
|
||||||
return "✓ Excused"
|
return "✓ Excused"
|
||||||
# if excused is False or excused == 0:
|
if result is False:
|
||||||
else:
|
|
||||||
return "✗ Unexcused"
|
return "✗ Unexcused"
|
||||||
return "? Unknown"
|
return "? Unknown"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue