From 6a72809817ac728f0b18c7d2a2a9f35043ac8d70 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Oct 2025 10:49:25 +0000 Subject: [PATCH] Fix Phase 3 logic for source_system_wins: when Google event is missing and source is Google, propagate delete to Advoware instead of recreating. --- .../advoware_cal_sync/calendar_sync_event_step.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py index a0267497..110e0633 100644 --- a/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py +++ b/bitbylaw/steps/advoware_cal_sync/calendar_sync_event_step.py @@ -494,14 +494,14 @@ async def handler(event, context): async with conn.transaction(): await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id']) elif row['source_system'] == 'google' and row['advoware_write_allowed']: - # Recreate in Advoware + # Propagate delete to Advoware try: - new_frnr = await safe_create_advoware_appointment(advoware, standardize_appointment_data(google_map[event_id], 'google'), employee_kuerzel, row['advoware_write_allowed']) + await safe_delete_advoware_appointment(advoware, frnr, row['advoware_write_allowed']) async with conn.transaction(): - await conn.execute("UPDATE calendar_sync SET advoware_frnr = $1, sync_status = 'synced' WHERE sync_id = $2;", int(new_frnr), row['sync_id']) - logger.info(f"Phase 3: Recreated Advoware appointment {new_frnr} for sync_id {row['sync_id']}") + await conn.execute("UPDATE calendar_sync SET deleted = TRUE, sync_status = 'synced' WHERE sync_id = $1;", row['sync_id']) + logger.info(f"Phase 3: Propagated delete to Advoware for sync_id {row['sync_id']}") except Exception as e: - logger.warning(f"Phase 3: Failed to recreate Advoware for sync_id {row['sync_id']}: {e}") + logger.warning(f"Phase 3: Failed to delete Advoware for sync_id {row['sync_id']}: {e}") async with conn.transaction(): await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id']) else: