-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Enhanced Reading Log Exports #6621
Merged
mekarpeles
merged 2 commits into
internetarchive:master
from
cclauss:enhanced_reading_log
Jul 14, 2022
Merged
Enhanced Reading Log Exports #6621
mekarpeles
merged 2 commits into
internetarchive:master
from
cclauss:enhanced_reading_log
Jul 14, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2098c9a
to
8abf80e
Compare
84372f6
to
a1ad646
Compare
This was referenced Jun 9, 2022
8a6e598
to
aaf2ed8
Compare
0749dca
to
3d98d23
Compare
mekarpeles
pushed a commit
that referenced
this pull request
Jul 14, 2022
* psf/black: core/bookshelves and upstream/account Canonical formatting will make future diffs easier to read thus making pull requests easier to review. `openlibrary/core/bookshelves.py` will be modified in both #6621 `openlibrary/plugins/upstream/account.py` will be modified in both #6621 and #6653 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3d98d23
to
fbe1af4
Compare
for more information, see https://pre-commit.ci
mekarpeles
approved these changes
Jul 14, 2022
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.
LGTM, only concern is Reading Logs with e.g. 10k+ items (if we're building the csv in memory) OR if we have multiple patrons doing exports at the same time, a more tenable solution could be to use a temp file (instead of memory).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
export
Priority: 1
Do this week, receiving emails, time sensitive, . [managed]
State: Blocked
Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed]
Theme: Reading Log
Related to workflows for creating, modifying, displaying a user's reading log. [managed]
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #6519
Blocked by #6734-- Rebase this PR after 6734 lands.Related to #6645 and #6653 which also use
csv_string()
.Export your Reading Log
with attention to adding more fields and without building large lists in memory which makes this process unwieldy for users with large reading lists.iterate_users_logged_books()
to get around the bug discussed at the bottom ofget_users_logged_books()
generate_reading_log()
to build the CSV by yielding one line at a time. (lower memory footprint)works, editions, authors, redirectsmy_rating, date_read, read_countCurrent output: OpenLibrary_ReadingLog(65).csv or see Screenshots below.
What code returns the results for:
The
/api/books
endpoint does not return enough information...ol_get_many_as_dict()
results are missing keyscovers
anddescription
but we don't need them for CSV.Being able to instantiate a
openlibrary.code.models.Work
would substantially reduce code complexity but this class has no.__init__()
method. If I know the key (e.g./works/OL8193488W
), how can I get anopenlibrary.code.models.Work
instance for that key?Answer:
web.ctx.site.get(key)
As in
work: Work = web.ctx.site.get("/works/OL8193488W")
returns anopenlibrary.plugins.upstream.models.Work
Technical
Testing
In one terminal tab:
docker compose up
In another terminal tab: open http://localhost:8080
Search on
Twain
and set one book each to:Want to Read
,Currently Reading
,Already Read
and add star ratings.On http://localhost:8080/account/import click Export your Reading Log -->
Download (.csv format)
Screenshot
Stakeholders @mheiman, @Fl0rent