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

Fix web book toast message not matching the web book read #9663

Conversation

scottbarnes
Copy link
Collaborator

Closes #9639

This PR stops non-DirectProvider web books from being matched as DirectProviders.

It also stops every DirectProvider book on a page from triggering the same toast message.

Technical

With respect to the first issue:
The Storage objects that ultimately come from SearchResponse have Acquisition objects in their providers fields, so every web book search result will have a providers attribute.

This PR limits the matching for DirectProvider to cases where the Acquisition object has a value other than None, which is the default initialization value for Acquisition.provider_name.

More exploration will be needed to see whether a similar mis-match problem occurs when there is more than one Acquisition per Work.

With respect to the second issue:
The direct_read_button.html needs a unique data-toast-trigger per domain, otherwise every DirectProvider book, when multiple are displayed from different providers, will have trigger the same class id.

Testing

Visit https://testing.openlibrary.org/search?q=format%3A%22Web+book%22&mode=everything&page=2

  1. Click something other than the first result, or an OpenStax book, and verify the toast looks correct for that specific provider.
  2. Now click an OpenStax book and ensure you see the OpenStax toast rather than the generic DirectProvider toast, which would simply mention the domain where the book is available, and not say anything about OpenStax specifically.

Screenshot

Stakeholders

@github-actions github-actions bot added the Priority: 2 Important, as time permits. [managed] label Jul 31, 2024
@scottbarnes scottbarnes force-pushed the 9639/fix/ensure-web-book-toast-message-matches-the-web-book-read branch 2 times, most recently from a4b93b0 to 8d930d0 Compare July 31, 2024 01:50
@scottbarnes scottbarnes added On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing Theme: Trusted Book Providers labels Jul 31, 2024
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm! One awkward potential change... This code's arch is a little difficult unfortunately! I'm not sure if there's a way we can simplify it rn. Thank you for trudging through it!

openlibrary/book_providers.py Outdated Show resolved Hide resolved
@cdrini cdrini self-assigned this Jul 31, 2024
@scottbarnes scottbarnes force-pushed the 9639/fix/ensure-web-book-toast-message-matches-the-web-book-read branch 4 times, most recently from 604ba3c to b3fb885 Compare August 1, 2024 06:08
scottbarnes and others added 4 commits August 5, 2024 14:37
This commit stops non-DirectProvider web books from being matched as
`DirectProvider`s.

The `Storage` objects that ultimately come from `SearchResponse` have
`Acquisition` objects in their `providers` fields, so every web book
search result will have a `providers` attribute.

This commit limits the matching for `DirectProvider` to cases where the
`Acquisition` object has a value other than `None`, which is the default
initialization value for `Acquisition.provider_name`.

More exploration will be needed to see whether a similar mis-match
problem occurs when there is more than one `Acquisition` per `Work`.
The `direct_read_button.html` needs a unique `data-toast-trigger` per
domain, otherwise every `DirectProvider` book, when multiple are
displayed from different providers, will have trigger the same class id.
Co-authored-by: Drini Cami <cdrini@gmail.com>
@scottbarnes scottbarnes force-pushed the 9639/fix/ensure-web-book-toast-message-matches-the-web-book-read branch 3 times, most recently from bafeb9a to 04708e6 Compare August 7, 2024 02:00
@cdrini cdrini added Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] Priority: 1 Do this week, receiving emails, time sensitive, . [managed] and removed Priority: 2 Important, as time permits. [managed] labels Aug 9, 2024
@scottbarnes scottbarnes force-pushed the 9639/fix/ensure-web-book-toast-message-matches-the-web-book-read branch from 04708e6 to d6c8001 Compare August 9, 2024 16:05
@github-actions github-actions bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Aug 9, 2024
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm! Tested IA-only, format: web book, publisher:librivox and all looking good 👍

@cdrini cdrini changed the title 9639/fix/ensure web book toast message matches the web book read Fix web book toast message not matching the web book read Aug 9, 2024
@cdrini cdrini merged commit 04fcf45 into internetarchive:master Aug 9, 2024
4 checks passed
@scottbarnes scottbarnes deleted the 9639/fix/ensure-web-book-toast-message-matches-the-web-book-read branch August 11, 2024 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing Priority: 1 Do this week, receiving emails, time sensitive, . [managed] Theme: Trusted Book Providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web books incorrectly select provider + display incorrect toast
2 participants