Skip to content

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

Merged
elfkuzco merged 1 commit intomainfrom
fix-retention-rules
May 11, 2026
Merged

fix retention rules to always keep latest version of two recent months#271
elfkuzco merged 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 (a7bc54a).
⚠️ Report is 4 commits behind head on main.

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.

Copy link
Copy Markdown
Contributor

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

This is indeed the good algorithm and more intelligible than my explanations ^^

@elfkuzco elfkuzco force-pushed the fix-retention-rules branch from 5726da8 to a7bc54a Compare May 11, 2026 08:46
@elfkuzco elfkuzco merged commit 5aab3c6 into main May 11, 2026
4 of 5 checks passed
@elfkuzco elfkuzco deleted the fix-retention-rules branch May 11, 2026 09:06
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

2 participants