(20260309) Added caching to avoid unchanged attendance calls and added logic to check for custom overtime thresholds.
This commit is contained in:
+14
-6
@@ -268,6 +268,7 @@ async def today_cron(
|
||||
async def set_scheduler(
|
||||
cosec_creds: dict,
|
||||
tcaoff_client: AsyncTheCAOffice,
|
||||
immediate: bool = False,
|
||||
test_mode: bool = False
|
||||
) -> None:
|
||||
|
||||
@@ -276,25 +277,26 @@ async def set_scheduler(
|
||||
foreground task happens in a loop.
|
||||
:param cosec_creds: The credentials to use to log into Matrix COSEC.
|
||||
:param tcaoff_client: The client to interact with TCAOFF.
|
||||
:param test_mode: If True, the scheduler will be ignored and the process will be run once immediately.
|
||||
:param immediate: If True, the process will run immediately first and then the scheduler will be set. If False, only
|
||||
the scheduler will be set.
|
||||
:param test_mode: If True, records will be fetched from cache instead of Cosec.
|
||||
:return: None.
|
||||
"""
|
||||
|
||||
# If in test mode:
|
||||
if test_mode:
|
||||
if immediate:
|
||||
printer("Starting Test")
|
||||
await yesterday_cron(
|
||||
cosec_creds = copy.deepcopy(cosec_creds),
|
||||
tcaoff_client = tcaoff_client,
|
||||
# test_mode = test_mode
|
||||
test_mode = test_mode
|
||||
)
|
||||
await today_cron(
|
||||
cosec_creds = copy.deepcopy(cosec_creds),
|
||||
tcaoff_client = tcaoff_client,
|
||||
# test_mode = test_mode
|
||||
test_mode = test_mode
|
||||
)
|
||||
printer("Test Done")
|
||||
return
|
||||
printer("Immediate run done.")
|
||||
|
||||
# If not in test mode, we continue with the scheduler.
|
||||
# Create the scheduler:
|
||||
@@ -355,6 +357,11 @@ if __name__ == "__main__":
|
||||
action = "store_true",
|
||||
default = False,
|
||||
)
|
||||
ap.add_argument(
|
||||
"--immediate",
|
||||
action = "store_true",
|
||||
default = False,
|
||||
)
|
||||
ap.add_argument(
|
||||
"--verbose",
|
||||
action = "store_true",
|
||||
@@ -383,5 +390,6 @@ if __name__ == "__main__":
|
||||
asyncio.run(set_scheduler(
|
||||
cosec_creds = cosec_creds,
|
||||
tcaoff_client = tcaoff_client,
|
||||
immediate = args.immediate,
|
||||
test_mode = args.test
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user