Skip to content

feat(retention): data-retention purge#86

Merged
mpge merged 1 commit into
mainfrom
feat/data-retention
Jun 26, 2026
Merged

feat(retention): data-retention purge#86
mpge merged 1 commit into
mainfrom
feat/data-retention

Conversation

@mpge

@mpge mpge commented Jun 26, 2026

Copy link
Copy Markdown
Member

Ports data retention to Go, mirroring the Phoenix escalated.purge_expired task and the Laravel escalated:purge-expired command.

What

  • RetentionService — purges attachments + audit logs older than the configured retention policy (retention_attachments / retention_audit_logs settings → shared day map: 90_days/180_days/365_days/1_year/2_years/3_years/5_years; never/unknown = disabled).
  • Closed-ticket retention is reported only, not enforced — that requires a soft-delete grace period (a deleted_at column the schema lacks). Matches the Phoenix behavior and ties into the closed-ticket-purge decision (feat(email): add services/email.MessageIdUtil for RFC 5322 + signed Reply-To #27).
  • POST /admin/data-retention/purge (admin-gated) in both routers. ?dry_run=1 reports counts without deleting.

Verification

  • go build ./... clean; new files 0 golangci-lint issues (the 6 reported are pre-existing in chat_session_service_test.go; only-new-issues mode ignores them).
  • TestRetentionDays / TestRetentionCutoff (pure) + TestPurgeExpired (real SQLite: dry-run reports without deleting, real run deletes only the expired row).
  • Full go test ./... passes.

Port data retention from the reference. Adds a RetentionService that purges
attachments and audit logs older than the configured retention policy
(settings retention_attachments / retention_audit_logs, mapped via the
shared day map: 90_days/180_days/365_days/1_year/2_years/3_years/5_years).
Closed-ticket retention is reported only, not enforced — that needs a
soft-delete grace period (a deleted_at column the schema lacks), matching
the Phoenix purge task.

Exposes POST /admin/data-retention/purge (admin-gated, ?dry_run=1 to report
without deleting) in both routers. Pure day-map/cutoff helpers are unit-
tested; PurgeExpired is covered against a real SQLite store.
@mpge mpge merged commit c29d649 into main Jun 26, 2026
2 checks passed
@mpge mpge deleted the feat/data-retention branch June 26, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant