-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix documentation of getResults #597
Conversation
Codecov Report
@@ Coverage Diff @@
## master #597 +/- ##
=======================================
Coverage 82.78% 82.78%
=======================================
Files 91 91
Lines 3822 3822
Branches 1703 1703
=======================================
Hits 3164 3164
Misses 657 657
Partials 1 1
Continue to review full report at Codecov.
|
@maneeshpm LGTM, see kiwix/libkiwix#597 as well |
20ecee8
to
5c2c3ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! It seems that it is not a simple documentation fix.
https://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html#a1f2e35f79bc731bebfbdaceda17b9892 indeed takes a maxResults, not a end.
So the previous code was buggy. We must check in all our user code how this is used. And add unit test getting range of results in the middle of the search to test this.
@mgautierfr Another possible solution is, instead of changing any of our existing user code, we modify |
@maneeshpm I'm not in favour of generating an exception here for that. Your fix seems proper to me, it just has to be tested properly. Keep in mind the libzim should be easy to use. |
@kelson42 I agree. We can go ahead and create corresponding tickets to "Check proper usage of getResults" in the rest of our projects and check them one by one. |
@maneeshpm Usually I'm not in favour to create test dedicated ticket excpet if there is a really good reason. Creating automated tests is part of the feature/bugfix development and multiplicatying tickets without reasons just makes things uselessly more complex. IMO it should be done in this PR, or do you see a really good reason to not do it now? |
@kelson42 I meant in the rest of our projects like kiwix-destop where this might be causing an issue, but we will have to check. I will add a test for libzim in this pr itself. |
@maneeshpm OK, I understand better. Once the PR is completed, would be great if you could check that the following repository are not impacted by a wrong assumption about
And if you see something just open a ticket then. |
5c2c3ea
to
c278454
Compare
c278454
to
6b098c4
Compare
Search::getResult(start, end) seems to be broken for getting results in range that not starting with 0.
getReturn should follow the same convention used by Xapian for consistency. The second argument maxResults is the maximum number of results to return starting from the first argument start.
6b098c4
to
6a0bcbe
Compare
@mgautierfr Can we merge this? |
Fixes #596
I propose we should follow the same convention as used by Xapian for consistency. That is, rather than keeping the second argument of
Search::getResults(start, end)
asend
of range, we should usemaxResults
as the second argument. This way:getResult(start, maxResults)
will return results in the range(start, start + maxResults)
This makes use of API much easier and will require just a documentation fix. We need to fix the rest of the projects accordingly(even though they still work and won't break after this change) for which issues are being created.