Skip to content

refactor: simplify EventRepository query/purge complexity#625

Open
Ferryx349 wants to merge 1 commit into
cameri:mainfrom
Ferryx349:m2
Open

refactor: simplify EventRepository query/purge complexity#625
Ferryx349 wants to merge 1 commit into
cameri:mainfrom
Ferryx349:m2

Conversation

@Ferryx349
Copy link
Copy Markdown
Collaborator

Description

This PR simplifies EventRepository by breaking down high-complexity logic in filter construction and retention purge flow.
It refactors applyFilterConditions into smaller helpers for hex and generic tag criteria handling, while preserving SQL behavior.
It also refactors deleteExpiredAndRetained into clearer steps (candidate selection, whitelist handling, purge count mapping).

Related Issue

Fixes- #46

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 24, 2026

🦋 Changeset detected

Latest commit: b9fc056

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 24, 2026

Coverage Status

coverage: 65.89% (+0.8%) from 65.119% — Ferryx349:m2 into cameri:main

Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
@Ferryx349
Copy link
Copy Markdown
Collaborator Author

resolved conflicts

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors EventRepository to reduce method complexity while preserving existing SQL/query behavior, focusing on subscription filter construction and retention purge flow (Issue #46).

Changes:

  • Refactors applyFilterConditions into focused helpers for hex criteria grouping and generic tag criteria handling.
  • Refactors deleteExpiredAndRetained into clearer steps (candidate selection, whitelist handling, purge count mapping) and introduces small constants for retention math/batch size.
  • Adds/extends unit tests to cover retention purge query construction and purge count mapping.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/repositories/event-repository.ts Splits complex filter and retention purge logic into smaller private helpers while keeping the generated SQL equivalent.
test/unit/repositories/event-repository.spec.ts Adds tests for retention-disabled behavior, purge query SQL construction, and purge result counting logic.
.changeset/vast-signs-melt.md Adds a patch changeset documenting the EventRepository refactor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants