feat: add new category and days to schedule argument

🛠️ myice.py -> Added new enum value 'u111' to AgeGroup, modified get_schedule function to accept num_days parameter, added num_days option to schedule function.
This commit is contained in:
2024-11-27 14:32:51 +01:00
parent 5bf970ed26
commit 6b37e0fcc2
+5 -3
View File
@@ -31,6 +31,7 @@ class AgeGroup(str, Enum):
u13p = "U13 (Prép)" u13p = "U13 (Prép)"
u15t = "U15 (Top)" u15t = "U15 (Top)"
u15a = "U15 (A)" u15a = "U15 (A)"
u111 = "U11 (1)"
class EventType(str, Enum): class EventType(str, Enum):
@@ -141,13 +142,13 @@ def wrapper_session(func):
@wrapper_session @wrapper_session
def get_schedule() -> str: def get_schedule(num_days: int) -> str:
global session global session
global userid global userid
assert session and userid assert session and userid
now = datetime.datetime.now() now = datetime.datetime.now()
date_start = now date_start = now
date_end = date_start + datetime.timedelta(days=7) date_end = date_start + datetime.timedelta(days=num_days)
r = session.post( r = session.post(
"https://app.myice.hockey/inc/processclubplanning.php", "https://app.myice.hockey/inc/processclubplanning.php",
data={ data={
@@ -208,11 +209,12 @@ def schedule(
"--outfile", "-o", help="file to write result to, or stdout if none" "--outfile", "-o", help="file to write result to, or stdout if none"
), ),
] = None, ] = None,
num_days: Annotated[int, typer.Option("--days")] = 7,
): ):
""" """
Fetch schedule as json Fetch schedule as json
""" """
schedule = get_schedule() schedule = get_schedule(num_days)
if outfile: if outfile:
with outfile.open("w") as f: with outfile.open("w") as f:
f.write(schedule) f.write(schedule)