Skip to content
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

Allow kiwix-serve to get suggestions of custom range #591

Merged
merged 1 commit into from
Aug 20, 2021

Conversation

maneeshpm
Copy link
Contributor

Fixes openzim/libzim#242

This PR will allow kiwix serve to retrieve suggestions of a given range that can be specified in the front end call. These changes will open up the backend to implement continuous scroll feature as specified in the issue. But that is rather working on the front end side and this PR is only "allowing" to enable the feature.

Changes included in this PR:

  • check for two new arguments start, suggestionLength in the handle_suggest API that will retrieve suggestions in the range given by (start, start+suggestionLength).

@codecov
Copy link

codecov bot commented Jul 25, 2021

Codecov Report

Merging #591 (7d67569) into fix_get_results (20cdefc) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

❗ Current head 7d67569 differs from pull request most recent head af825d4. Consider uploading reports for the commit af825d4 to get more accurate results
Impacted file tree graph

@@                 Coverage Diff                 @@
##           fix_get_results     openzim/libzim#591      +/-   ##
===================================================
- Coverage            64.92%   64.91%   -0.01%     
===================================================
  Files                   53       53              
  Lines                 3738     3737       -1     
  Branches              1881     1874       -7     
===================================================
- Hits                  2427     2426       -1     
  Misses                1309     1309              
  Partials                 2        2              
Impacted Files Coverage Δ
include/searcher.h 33.33% <ø> (ø)
src/searcher.cpp 47.10% <44.44%> (ø)
src/server/internalServer.cpp 83.58% <100.00%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20cdefc...af825d4. Read the comment docs.

@@ -353,6 +353,7 @@ SuggestionsList_t getSuggestions(const zim::Archive* const archive,
// TODO: This case should be handled by libzim
std::vector<std::string> variants = getTitleVariants(queryString);
int currCount = 0;
int suggestionCount = end - start;
Copy link
Contributor Author

@maneeshpm maneeshpm Jul 25, 2021

Choose a reason for hiding this comment

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

Worth mentioning that getting results of a certain range in a non-Xapian based search is not supported as of now, so we will simply consider the count of suggestions here.
This will anyway have to be implemented on libzim side after openzim/libzim#574

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

Code is good but I'm a bit disturbed by the idea of adding a somehow hidden feature, not tested and not used.

It would be nice to have this change associated with a change in the front end to use it (and some tests of the feature)

src/server/internalServer.cpp Outdated Show resolved Hide resolved
@kelson42
Copy link
Collaborator

Code is good but I'm a bit disturbed by the idea of adding a somehow hidden feature, not tested and not used.

It would be nice to have this change associated with a change in the front end to use it (and some tests of the feature)

I'm supportive of this comment. IMO, we should have a dedicated automated test able that way for example to retrieve by range of 10 suggestions, around 100 suggestions. The case of stopping before the end, and reaching the end of available suggestions should be tested. Cases of giving out-of-bands values to the ABI should be properly tested as well.

@maneeshpm
Copy link
Contributor Author

Thanks for the suggestion @kelson42 @mgautierfr. It revealed a nasty error openzim/libzim#595. Working on a fix, shouldn't take much time.

@maneeshpm maneeshpm changed the base branch from master to fix_get_results July 30, 2021 17:34
@maneeshpm
Copy link
Contributor Author

maneeshpm commented Jul 30, 2021

@kelson42 Added some unit tests for checking the added changes.

Rebasing the PR on openzim/libzim#597 just to show the solution employed to our earlier tackled issue is employed here as well.

@kelson42
Copy link
Collaborator

@MananJethwani Would you please verify that this feature would effectively allow us for example to provide an "infinite" scroll possibility in the suggestion selecbox?

@maneeshpm maneeshpm force-pushed the fix_get_results branch 2 times, most recently from 796d3d8 to c88dfa2 Compare August 4, 2021 13:09
@maneeshpm maneeshpm force-pushed the fix_get_results branch 3 times, most recently from 9cff130 to 9addd82 Compare August 4, 2021 13:51
Base automatically changed from fix_get_results to master August 4, 2021 13:58
@kelson42
Copy link
Collaborator

@MananJethwani Coukd you please validate this PR? See my latest comment.
@maneeshpm What is the overall status? Are we expecting new review by @mgautierfr?

@maneeshpm maneeshpm force-pushed the suggestion_range branch 2 times, most recently from 2896b35 to fad6919 Compare August 11, 2021 06:49
@maneeshpm
Copy link
Contributor Author

@kelson42 The last review pointed out a lack of unit testing in this pr. I have added some new tests to demonstrate the features added. And hence, a new review is necessary.

@kelson42
Copy link
Collaborator

@maneeshpm Can you please rebase this branch?

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

It seems the two first commits are already merged in master.
They are keep in the PR by the rebase because they are using tab instead of space. We should simply remove them.

The update fix only one of my remarks. It add unit-test.
But we are adding a feature that no one is using. It would be nice to
make the kiwix-serve "frontend" uses the feature provided by the backend.
But this is js development and it should probably be made by a different developer. @kelson42 I let you decide on this. Having unit-test is enough for me.

@maneeshpm maneeshpm force-pushed the suggestion_range branch 2 times, most recently from 199bf96 to 8066232 Compare August 19, 2021 14:06
@maneeshpm
Copy link
Contributor Author

Rebased to fix the commit history.
I agree with @mgautierfr, will let anyone with experience in js build the front end. Till now, we have "enabled" the option from the backend.

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

Sorry, I'm adding a late remark.

src/server/internalServer.cpp Outdated Show resolved Hide resolved
This will allow handle_suggest API to accept two arguments `start` and
`suggestionLength` that will allow handle_suggest to retrieve
suggestions in the given range rather than the default 0-10 range.
@kelson42 kelson42 merged commit ea6413f into master Aug 20, 2021
@kelson42 kelson42 deleted the suggestion_range branch August 20, 2021 06:09
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.

Allow kiwix-serve to retrieve suggestions in the range provided by users
3 participants