Fix Phase 3 logic for source_system_wins: when Google event is missing and source is Google, propagate delete to Advoware instead of recreating.
This commit is contained in:
@@ -494,14 +494,14 @@ async def handler(event, context):
|
|||||||
async with conn.transaction():
|
async with conn.transaction():
|
||||||
await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id'])
|
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']:
|
elif row['source_system'] == 'google' and row['advoware_write_allowed']:
|
||||||
# Recreate in Advoware
|
# Propagate delete to Advoware
|
||||||
try:
|
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():
|
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'])
|
await conn.execute("UPDATE calendar_sync SET deleted = TRUE, sync_status = 'synced' WHERE sync_id = $1;", row['sync_id'])
|
||||||
logger.info(f"Phase 3: Recreated Advoware appointment {new_frnr} for sync_id {row['sync_id']}")
|
logger.info(f"Phase 3: Propagated delete to Advoware for sync_id {row['sync_id']}")
|
||||||
except Exception as e:
|
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():
|
async with conn.transaction():
|
||||||
await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id'])
|
await conn.execute("UPDATE calendar_sync SET sync_status = 'failed' WHERE sync_id = $1;", row['sync_id'])
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user