Skip to content

query db for latest books during zim URL computation#262

Open
elfkuzco wants to merge 1 commit intomainfrom
zim-view-url
Open

query db for latest books during zim URL computation#262
elfkuzco wants to merge 1 commit intomainfrom
zim-view-url

Conversation

@elfkuzco
Copy link
Copy Markdown
Contributor

Rationale

This PR refactors the way zim URLs are computed by using a subquery to get the books which are the latest per title/flavor combination. It then joins this subquery to the original query and building up a column is_latest if the current book date matches the one from the latest subquery. This way, we can/cannot have a view URL depending on if the latest book is included in the book IDs to compute their URL.

Changes

  • build up the list of titles for all the book IDs given
  • use subquery to get the latest books for the titles
  • join original query to the subquery since all the books will always have one title_id/flavor. This is necessary to build up the is_latest property
  • sort books by zim metadata Date first before created_at. This will fix the issue in Computation of ZIM to view has a bug when title changed #253

This fixes #253
This fixes #254

@elfkuzco elfkuzco self-assigned this Apr 29, 2026
@elfkuzco elfkuzco requested a review from benoit74 April 29, 2026 10:31
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.38%. Comparing base (b78d74a) to head (aca6d90).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
backend/src/cms_backend/db/books.py 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #262      +/-   ##
==========================================
- Coverage   81.41%   81.38%   -0.04%     
==========================================
  Files          53       53              
  Lines        2228     2235       +7     
  Branches      216      218       +2     
==========================================
+ Hits         1814     1819       +5     
  Misses        357      357              
- Partials       57       59       +2     

☔ 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.

Querying for a single ZIM URLs gives wrong results Computation of ZIM to view has a bug when title changed

1 participant