Skip to content

Conversation

@gileslloyd
Copy link
Contributor

What problem does this PR solve?

When the metadata cache for documents is being built, we build it page by page in a while loop. We were deciding when to break by using the number of pages we'd fetched so far multiplied by the number of documents per page and comparing to the total to understand how many documents were remaining. The problem was we were incrementing the page count before this calculation, ensuring that we missed the last page of documents.

For example.
I have 288 documents. If I use a page size of 30 then there are 10 pages of documents: 288 / 30 = 9.6

So once we've fetched 9 pages of documents we'd have 270 documents cached: 9 * 30 = 270 which leaves 18 documents remaining on the last page. But since we increment the page count first the calculation to determine how many documents remain is:
288 - (10*30) = -12 instead of 288 - (9*30) = 18. The result is the last 18 documents are missed.

We could just move the page increment after this calculation but I feel like this solution is over-complicated. The cleaner thing to do is just break on the first page with no documents.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Feb 13, 2026
@yingfeng yingfeng added the ci Continue Integration label Feb 13, 2026
@yingfeng yingfeng marked this pull request as draft February 13, 2026 07:30
@yingfeng yingfeng marked this pull request as ready for review February 13, 2026 07:30
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.18%. Comparing base (bc9ed24) to head (750ff74).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13141      +/-   ##
==========================================
- Coverage   47.14%   44.18%   -2.96%     
==========================================
  Files          43       43              
  Lines        9501     9501              
  Branches      107      107              
==========================================
- Hits         4479     4198     -281     
- Misses       5013     5284     +271     
- Partials        9       19      +10     

☔ 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

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants