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

OpdsCatalog::getSearchUrl() #527

Merged
merged 1 commit into from
Jun 30, 2021
Merged

Conversation

veloman-yunkan
Copy link
Collaborator

Fixes #480.

Must be merged after #526.

This is a preliminary implementation of OPDS search url generation targeting the new API introduced by the yet unmerged #492.

Note that #488 has enabled us to search by all fields via the query parameter. For example a search by category can be done in two ways:

  1. (old) search_endpoint?category=whatever
  2. (new) search_endpoint?q=category:whatever

Internally, the old approach is converted to an equivalent of the new one with the slight difference of not assuming partial query (which is the default mode for the q parameter).

Some fields (creator, publisher) are not exposed for searching in the old scheme but are available via the new scheme.

Now the question is which one of the two schemes should be utilized for the search URL generation?

Another question is what should be done about the filtering criteria Filter::local(), Filter::remote(), Filter::remote()? They have never been exposed through the OPDS search API.

TODOs:

  • Don't ignore the Filter::maxSize() & Filter::rejectTags() filtering criteria.

@kelson42
Copy link
Collaborator

@veloman-yunkan Thx, do you have a kiwix-desktop related PR, so I can just test if it works (no regression) from user perspective?

@veloman-yunkan
Copy link
Collaborator Author

@veloman-yunkan Thx, do you have a kiwix-desktop related PR, so I can just test if it works (no regression) from user perspective?

No. It won't work until the new OPDS catalog API is merged and goes live on library.kiwix.org (or you will have to test with a custom-built kiwix-serve incorporating #492).

@kelson42
Copy link
Collaborator

@veloman-yunkan Really hard to me then to verify it works fine from a user persective. Will let @mgautierfr do the review.

@kelson42 kelson42 removed their request for review May 16, 2021 07:13
Base automatically changed from lizim_search_api_change to master May 17, 2021 13:06
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.

Now the question is which one of the two schemes should be utilized for the search URL generation?

I prefer the old one. Mainly because it is easier to read.

src/opds_catalog.cpp Show resolved Hide resolved
include/opds_catalog.h Outdated Show resolved Hide resolved
Comment on lines +68 to +71
if ( searchString.empty() )
return opdsSearchEndpoint;
else
return opdsSearchEndpoint + ("?" + searchString);
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we have buildSearchString adding the ? itself if needed ?
Then we would simply have to always add opdsSearchEndpoint and searchString.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried it but didn't like the result. getSearchUrl() starts looking like a plagiarist that delegates all work to a ghost writer but receives all the credit. The current division of work between getSearchUrl() and buildSearchString() is more balanced.

@kelson42
Copy link
Collaborator

what is the status here?

@veloman-yunkan
Copy link
Collaborator Author

@kelson42 I will finalize this PR after #492 is merged (which introduces new catalog API that is assumed here).

@stale
Copy link

stale bot commented Jun 5, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Jun 5, 2021
@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #527 (c3595aa) into master (4124ad3) will increase coverage by 0.19%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master     #527      +/-   ##
==========================================
+ Coverage   65.05%   65.25%   +0.19%     
==========================================
  Files          51       52       +1     
  Lines        3626     3649      +23     
  Branches     1825     1841      +16     
==========================================
+ Hits         2359     2381      +22     
- Misses       1265     1266       +1     
  Partials        2        2              
Impacted Files Coverage Δ
src/opds_catalog.cpp 100.00% <100.00%> (ø)
src/reader.cpp 44.11% <0.00%> (-0.17%) ⬇️

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 4124ad3...b5c1b26. Read the comment docs.

@kelson42
Copy link
Collaborator

@veloman-yunkan #492 has been merge, I guess nothing stops us anymore to finish this PR?

@veloman-yunkan
Copy link
Collaborator Author

@kelson42 This PR is finished and pending review by @mgautierfr

@mgautierfr
Copy link
Member

Nothing to say on the code.

I'm a bit less sure about the generated endpoint.
As the catalog V2 is not totally finalized, we may change the endpoints and we agree to not use them until we finish it (at least until we are confident enough to tell we can start us it).
If getSearchUrl use the v2 and we do a release with getSearchUrl then user will start to use it and start to use the v2 catalog. We have to be careful with this.

I will not block this PR for this, but I may block the next release however 🙂

@stale
Copy link

stale bot commented Jun 26, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label Jun 26, 2021
@mgautierfr mgautierfr force-pushed the catalog_search_url_generation branch from c3595aa to b5c1b26 Compare June 30, 2021 16:27
@stale stale bot removed the stale label Jun 30, 2021
@mgautierfr
Copy link
Member

rebase/fixup on master.

This PR is open for two long now. As we agree on the code we can merge it.
We will discuss again this v2 endpoint when we will do the release.

@kelson42 kelson42 merged commit 0594e60 into master Jun 30, 2021
@kelson42 kelson42 deleted the catalog_search_url_generation branch June 30, 2021 19:35
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.

Provide method which builds the OPDS URL
3 participants