Skip to content

fix retention rules to always keep latest version of two recent months#271

Open
elfkuzco wants to merge 1 commit intomainfrom
fix-retention-rules
Open

fix retention rules to always keep latest version of two recent months#271
elfkuzco wants to merge 1 commit intomainfrom
fix-retention-rules

Conversation

@elfkuzco
Copy link
Copy Markdown
Contributor

@elfkuzco elfkuzco commented May 6, 2026

Rationale

This PR fixes the retention rules by filtering books at the application level instead of the DB level. Consequently, since all prod books belonging to the title are loaded, we revise the algorithm as follows:

  • keep a list of the latest version from the two most recent periods. The two most recent periods may or may not include the recent/last month. This way, if there are books for the current month, then, they will surely take up the first slot. Older books may take up zero to two slots.
  • for all books originally selected, if book is older than 30 days and book doesn't appear in the list built up, mark it for deletion

This fixes #268

@elfkuzco elfkuzco self-assigned this May 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.49%. Comparing base (53ad7cf) to head (5726da8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
+ Coverage   81.39%   81.49%   +0.10%     
==========================================
  Files          55       55              
  Lines        2354     2356       +2     
  Branches      233      233              
==========================================
+ Hits         1916     1920       +4     
+ Misses        378      377       -1     
+ Partials       60       59       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Book retention rules are still a bit incorrect

1 participant