-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
My Books (Reading Log) add Search & Filter capability #5080
Comments
Implementation
For now, because this is expensive, we probably can't do real-time search (like we do on the topnav) Perhaps the actual solution is to use (a) use solr or (b) have this information mirrored in their archive.org items (privately) or (c) to include the book title in the bookshelves db (which may affect performance) |
In short we'd probably want a solr query like: {
'fq': 'key:(/works/OL1W OR /works/OL234W)', # You know but dynamic
'q.op': 'AND',
'q': q, # User query
'start': offset,
'rows': limit,
'fl': ','.join(DEFAULT_SEARCH_FIELDS), # From worksearch/code.py
'qt': 'standard',
'sort': 'work_count desc',
'wt': 'json',
'defType': 'edismax',
'qf': 'text title^20 author_name^20'
}, We should DRY this up more because it duplicates some of the search page logic, but this is fine for now. Pass through |
Yes, this would be a big win! e.g. Getting list of all work ids from a patrons reading log shelf and then limit a solr search to these IDs! |
I'd like to work on this, @mekarpeles. |
This should do the trick: do_search(
{'q': 'rowling' + ' key:(/works/OL1W OR /works/OL2W)'},
sort=None,
page=1,
rows=20,
) |
I am looking for an issue for my first contribution . Can you help me here. |
Describe the problem that you'd like solved
(What it would take to) add search capabilities to the Reading Log page.
Proposal & Constraints
Please note, that currently, this proposal will not work because book titles, authors, and the other data we'd like to search for are not kept in our ReadingLog db table, only the OL identifiers. We may be able to achieve this with solr in the future. But assuming we did have the desired info in our database (and as a thought exercise):
NOTE: Read first, Working with Reading Log here: #4267 (comment)
. In the future, we might want to use javascript (similar to how we the real-time Search box works at the top of the website):
public_my_books
controller method in https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/account.py#L733-L760 to accept a GET parameter. Already, the function expects apage
variable to be sent as a GET parameters (https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/account.py#L738) so accomplishing this should be as straightforward as adding another parameters like,i = web.input(page=1, search=None)
.i.search
query is present (e.g.if i.search
). If thei.search
value is present, we'll need change the linereadlog.get_works
call so this optionalsearch
parameter is passed along with our request for matching books.readlog
is an instance ofplugins.upstream.account.ReadingLog
(class defined here:openlibrary/openlibrary/plugins/upstream/account.py
Line 645 in 1f57759
get_works
method (openlibrary/openlibrary/plugins/upstream/account.py
Line 716 in 1f57759
search
parameter (e.g.(key, page=1, limit=RESULTS_PER_PAGE, search=None)
). ThisReadingLog.get_works
function essentially uses aKEYS
dictionary (defined here:openlibrary/openlibrary/plugins/upstream/account.py
Lines 654 to 660 in 1f57759
ReadingLog
methods referenced by theKEYS
dictionary (namely:get_waitlisted_editions
,get_loans
,get_want_to_read
,get_currently_reading
,get_already_read
) must thus also be updated to take an optionalsearch
parameter. Each of these functions ultimately makes an API call to the same function within ourBookshelves
API model:Bookshelves.get_users_logged_books
(https://github.com/internetarchive/openlibrary/blob/master/openlibrary/core/bookshelves.py#L118-L149)template
, thepublic_my_books
view/controller has been edited to expect asearch
parameter, thissearch
parameter is forwarded to ourreadlog.get_works
call, and thereadlog
object (i.e. theReadingLog
class) have all been updated to accept an optionalsearch
parameter, we'll then need to do the hard work of modifying the actual APIBookshelves.get_users_logged_books
(the thing which calls the database) to consider the possibility of an optional search parameter when requesting data from the database: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/core/bookshelves.py#L118-L149).Related to
#4262, #4267
Stakeholders
@cdrini
The text was updated successfully, but these errors were encountered: