Remove lock checking and setting from event step, keep only deletion in finally

This commit is contained in:
root
2025-10-24 00:44:31 +00:00
parent f6bcbe664c
commit 9a1eb5bf0b

View File

@@ -848,9 +848,9 @@ async def process_updates(state, conn, service, calendar_id, kuerzel, advoware,
await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id'])
CALENDAR_SYNC_LOCK_KEY = 'calendar_sync_lock'
async def handler(context):
async def handler(event_data, context):
"""Main event handler for calendar sync."""
kuerzel = context.input.data.get('kuerzel')
kuerzel = event_data.get('kuerzel')
if not kuerzel:
log_operation('error', "No kuerzel provided in event", context=context)
return {'status': 400, 'body': {'error': 'No kuerzel provided'}}
@@ -867,13 +867,6 @@ async def handler(context):
)
try:
if redis_client.get(employee_lock_key):
log_operation('info', f"Sync already running for {kuerzel}, skipping", context=context)
return {'status': 200, 'body': {'status': 'skipped', 'reason': 'sync_already_running', 'kuerzel': kuerzel}}
# Set lock for 30 minutes
redis_client.set(employee_lock_key, 'event', ex=1800)
log_operation('info', f"Lock set for {kuerzel}, starting sync", context=context)
log_operation('debug', "Initializing Advoware API", context=context)
advoware = AdvowareAPI(context)