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.
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
);
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 daysThen 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 theN
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 thecel.call_log_Id
column of the CEL entries associated to the deleted call logs tonull
, in order for the nextDAO.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 );