Fix fulltext search pagination: all pages returned identical results#11797
Fix fulltext search pagination: all pages returned identical results#11797
Conversation
Co-authored-by: mekarpeles <978325+mekarpeles@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a pagination bug in the fulltext search functionality where different page numbers were returning the same search results.
Changes:
- Fixed offset calculation logic in
fulltext_search_asyncby changing the default parameter fromoffset=0tooffset=None - Added comprehensive test coverage for pagination offset calculation including edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| openlibrary/core/fulltext.py | Changed default offset parameter from 0 to None to enable page-based offset calculation |
| openlibrary/tests/core/test_fulltext.py | Added test to verify pagination offset calculation for different pages and explicit offset override |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RayBB
left a comment
There was a problem hiding this comment.
@mekarpeles @copilot the tests and pre-commit are both failing for this PR.
|
@copilot the tests and pre-commit are both failing for this PR. |
Co-authored-by: cdrini <6251786+cdrini@users.noreply.github.com>
Fixed in de90d7f. The test was calling
Fixed in de90d7f. The test was calling |
RayBB
left a comment
There was a problem hiding this comment.
updated the tests to be useful. Put it on testing, and it's working great.
…/fix-fulltext-search-pagination Fix fulltext search pagination: all pages returned identical results
Fulltext search pagination (
/search/inside?page=N) returned identical results for all page numbers due to incorrect default parameter preventing offset calculation.Technical
Root cause:
fulltext_search_asyncusedoffset=0as default parameter. The conditionif offset is None:never triggered, sooffset = (page - 1) * limitnever executed.Fix: Changed default from
offset=0tooffset=None.Backward compatible: explicit
offsetvalues still override page calculation.Testing
Added
test_pagination_offset_calculationverifying:Test initially failed due to incorrect usage of
httpx_mock.reset(False). Fixed by removing the invalid parameter ashttpx_mock.reset()doesn't accept arguments.Screenshot
N/A - backend pagination logic only
Stakeholders
cc @mekarpeles
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.