Skip to main content

purge_older_than

Function purge_older_than 

Source
pub async fn purge_older_than(
    pool: &PgPool,
    retention_days: u32,
) -> AppResult<u64>
Expand description

Removes the audit entries older than retention_days (housekeeping, TEAMCRAFT_AUDIT_RETENTION_DAYS; the caller skips it for 0 = keep for ever) and records the removal as one audit.purge entry with the count and the time span removed – in one transaction, so entries never vanish without that record. Returns the number of entries removed.

§Invariants

  • Permission: none – the server’s housekeeping, no actor (“system”).
  • Data: only entries older than the cut-off, except the entries separation of duties still reads: logged edits (reviewers::EDIT_ACTIONS) of revisions that are still in work or review and preparing actions (changes::PREPARE_ACTIONS) of changes that are not yet released or cancelled – otherwise an editor could drop out of the four-eyes check; a retention of 0 days is refused (400).
  • Audit: one audit.purge entry when something was removed (only administrators see it, like every entry without an item, change or group).
  • Atomic: one transaction.