https://trello.com/c/a93Xv6Qo/71-admin-data-maintenance-truncate-audit-log-should-be-re-written
Proposed Algorithm
Audit log retention days (ARD)
- if blank, do not truncate audit log
- if not blank,
- select 1 day of audits from ARD->ARD+1
- select each auditBizId for that day (get the auditBizId and millis) , find the penultimate change to each bizId (if there is one) and delete all rows for that bizId less than that timestamp.
If some rows were deleted, step back one day and repeat the process.
- job should not run if it is already running
Once this has completed once, keep that date - from then only we only step back until that previous epoch date.
Start with an epoch of 1 Jan 2010.