(20260216) Attendance mark is now truly async.

This commit is contained in:
2026-02-16 14:32:43 +05:30
parent beca5e3127
commit 3079a8f6f0
5 changed files with 67 additions and 29 deletions
+44 -22
View File
@@ -137,7 +137,7 @@ async def yesterday_cron(
# for the driver's resources to get freed:
success = common.get_in_out_summary(
cosec_creds = cosec_creds,
from_dt = date_time.get_current_ist_date_time() - datetime.timedelta(days = 7),
from_dt = date_time.get_current_ist_date_time() - datetime.timedelta(days = 2),
to_dt = date_time.get_current_ist_date_time(),
cache_file = common.PREV_DAY_IN_OUT_SUMMARY_CACHE_FILE,
test_mode = test_mode
@@ -196,34 +196,56 @@ async def today_cron(
# Try the part that needs COSEC:
try:
# Get the Muster Roll and then wait
# # MUSTER-ROLL:
#
# # Get the Muster Roll and then wait
# # for the driver's resources to get freed:
# success = common.get_muster_roll(
# cosec_creds = cosec_creds,
# on_date = date_time.get_current_ist_date_time().replace(
# hour = 0,
# minute = 0,
# second = 0
# ),
# cache_file = common.PREV_DAY_IN_OUT_SUMMARY_CACHE_FILE,
# test_mode = test_mode
# )
#
# # Sync data between Cosec and TCAOFF:
# if success:
# print("MUSTER ROLL: Sync'ing with TCAOFF")
# cosec_muster_roll = json.from_file(common.MUSTER_ROLL_CACHE_FILE)
# await common.sync_branches_to_tcaoff(
# tcaoff_client = tcaoff_client,
# cosec_muster_roll = cosec_muster_roll,
# )
# await common.sync_departments_to_tcaoff(
# tcaoff_client = tcaoff_client,
# cosec_muster_roll = cosec_muster_roll,
# )
# await common.sync_teams_to_tcaoff(
# tcaoff_client = tcaoff_client,
# cosec_muster_roll = cosec_muster_roll,
# )
# IN-OUT SUMMARY:
# Get the previous day's In/Out Summary and then wait
# for the driver's resources to get freed:
success = common.get_muster_roll(
success = common.get_in_out_summary(
cosec_creds = cosec_creds,
on_date = date_time.get_current_ist_date_time().replace(
hour = 0,
minute = 0,
second = 0
),
cache_file = common.PREV_DAY_IN_OUT_SUMMARY_CACHE_FILE,
from_dt = date_time.get_current_ist_date_time().replace(hour = 0, minute = 0, second = 0, microsecond = 0),
to_dt = date_time.get_current_ist_date_time(),
cache_file = common.IN_OUT_SUMMARY_CACHE_FILE,
test_mode = test_mode
)
# Sync data between Cosec and TCAOFF:
if success:
print("MUSTER ROLL: Sync'ing with TCAOFF")
cosec_muster_roll = json.from_file(common.MUSTER_ROLL_CACHE_FILE)
await common.sync_branches_to_tcaoff(
printer("IN/OUT SUMMARY: Sync'ing with TCAOFF")
await common.sync_attendance_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
)
await common.sync_departments_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
)
await common.sync_teams_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
cosec_in_out_summary = json.from_file(common.IN_OUT_SUMMARY_CACHE_FILE),
)
# If something goes wrong in the COSEC step:
@@ -262,7 +284,7 @@ async def set_scheduler(
# 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),