Skip to content

feat(indexer): add configurable automatic event retention cleanup#210

Merged
therealjhay merged 3 commits into
Betta-Pay:mainfrom
Oyinkans0la12:feat/indexer-event-retention
Jun 30, 2026
Merged

feat(indexer): add configurable automatic event retention cleanup#210
therealjhay merged 3 commits into
Betta-Pay:mainfrom
Oyinkans0la12:feat/indexer-event-retention

Conversation

@Oyinkans0la12

Copy link
Copy Markdown
Contributor

Closes #77

Summary

Add configurable automatic cleanup of old indexer events to prevent unbounded database growth.

Changes

  • Added EVENT_RETENTION_DAYS configuration (default: 0, disabled)
  • Added cleanupOldEvents() for deleting expired events
  • Runs cleanup once on startup and every 24 hours when enabled
  • Deletes records in batches of 1000
  • Logs the number of events removed during each cleanup
  • Added/updated tests covering cleanup behavior

Configuration

Variable Default Behavior
EVENT_RETENTION_DAYS 0 Cleanup disabled
EVENT_RETENTION_DAYS > 0 Enabled Deletes events older than the configured retention period

Cleanup Behavior

When enabled:

  • Runs once during application startup
  • Runs every 24 hours thereafter
  • Deletes old events in batches of 1000
  • Logs the number of deleted events

Testing

Covered:

  • Cleanup disabled by default
  • Cleanup enabled
  • Retention cutoff calculation
  • Multi-batch deletion
  • Empty cleanup runs
  • Cleanup logging

Scope

This PR intentionally focuses only on configurable event retention cleanup. It does not redesign indexing, event persistence, scheduling infrastructure, or database architecture.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Oyinkans0la12 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@therealjhay

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

@Oyinkans0la12

Copy link
Copy Markdown
Contributor Author

Kindly resolve conflict

Done.

@therealjhay therealjhay merged commit bcc2f29 into Betta-Pay:main Jun 30, 2026
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.

Add event TTL and automatic cleanup

2 participants