wazo-call-logs cli: deleting call logs of last N days prevents CEL entries from being reprocessed

Description

Given that I want to delete call logs of the last few days in order to regenerate them(e.g. following a fix in wazo-call-logd)
When using wazo-call-logs -d N delete cli command to delete call logs over the last few days

Then the call log entries(CDR) are deleted, but CEL entries are left pointing to the deleted call logs

Then attempts to generate call logs for unprocessed CELs(e.g. wazo-call-logs -d N generate ) will miss those CELs and call logs for the N last days will remain missing.

Details

The code path for the wazo-call-logs -d N delete cli invocation fails to properly take care of the cleanup and reset the cel.call_log_Id column of the CEL entries associated to the deleted call logs to null, in order for the next DAO.cel.find_last_unprocessed call to account for them.

https://github.com/wazo-platform/wazo-call-logd/blob/4888e287c1a951588256bef4575410e7e536e00e/wazo_call_logd/manager.py#L24-L26

Workaround

Requires running raw sql:

UPDATE cel SET call_log_id = null WHERE call_log_id IS NOT NULL AND NOT EXISTS (> select id from call_logd_call_log as call_logs where call_logs.id = cel.call_log_id );

Zendesk Ticket IDs

None

Activity

Show:
Done

Details

Priority

Assignee

Reporter

Approvers

François Blackburn

Fix versions

Sprint

Labels

Zendesk Support

Created September 13, 2023 at 6:58 PM
Updated January 10, 2024 at 7:17 PM
Resolved January 10, 2024 at 5:03 PM

Flag notifications