Skip to content

Schedule and monitor stale draft cleanup in the backend - #535

Open
harryjupiter148 wants to merge 2 commits into
ZyntariHQ:mainfrom
harryjupiter148:main
Open

Schedule and monitor stale draft cleanup in the backend#535
harryjupiter148 wants to merge 2 commits into
ZyntariHQ:mainfrom
harryjupiter148:main

Conversation

@harryjupiter148

Copy link
Copy Markdown

Summary

Implemented scheduled cleanup for stale invoice drafts so expired drafts are automatically removed from storage instead of accumulating indefinitely.

The cleanup job is now wired into the running backend with configurable retention behavior and logging to make cleanup activity visible to maintainers and easier to verify operationally.

Related Issue(s)

Closes #519

Type of Change

  • Feature
  • Fix
  • Refactor
  • Documentation
  • Chore

Description

  • Wired the existing stale-draft cleanup logic into a scheduled backend job.
  • Added the required job scheduling configuration to run cleanup automatically on a defined schedule.
  • Added cleanup logging to provide visibility into scheduled execution and the number of stale drafts removed.
  • Defined draft retention behavior in a configurable manner so the retention period can be adjusted without changing the cleanup implementation.
  • Updated/added tests to verify stale-draft retention and cleanup behavior.
  • Kept the changes scoped to the invoice draft cleanup and scheduling functionality.

Testing Evidence

  • Verified that the backend builds successfully.
  • Ran the relevant invoice/draft cleanup tests.
  • Verified that stale drafts older than the configured retention period are identified and removed.
  • Verified that drafts within the retention period are preserved.
  • Verified that the scheduled cleanup job is registered and executes as expected.
  • Verified that cleanup activity is logged for operational visibility.

Checklist

  • Code builds successfully
  • Tests added/updated where applicable
  • Documentation updated if needed
  • Linked issue referenced
  • Ready for review

@Cedarich

Cedarich commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

@harryjupiter148 kindly fix

…o 22.x

- draft.service.spec.ts was not updated when ConfigService was added to
  DraftService's constructor in 65e99d3, causing NestJS DI to throw at
  compile time and all tests in that suite to fail with exit code 1
- Bump CI matrix node-version from 20.x (deprecated) to 22.x (LTS) to
  resolve the 'Node.js 20 is deprecated, being forced to Node.js 24'
  warning and ensure a predictable runtime
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.

Schedule and monitor stale draft cleanup in the backend

2 participants