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

Create a Trending Books Carousel in the Home page #6568

Conversation

dbouris
Copy link
Contributor

@dbouris dbouris commented May 19, 2022

Closes #6186

With this PR, a carousel containing the Today's Trending Books in the Home page.

Technical

The get_most_logged_books method used to fetch the Trending Books for the /trending/today page did not return the books in the correct format in order for the carousel to process and view them. So, we created the get_logged_books_carousel which calls get_most_logged_books and then formats the output. This created the carousel for the first step of the implementation.

Considering the second step and the carousels ability to load more books, we adjusted browse.json with adding the trending parameter. If trending = true, then the get_logged_books_carousel is called. To achieve pagination, the most_logged_books method gets the page number as a parameter. Lastly, we added an offset variable offset=(page-1)*limit and integrated it in the sql query.

Testing

If testing in a localhost environment make sure to mark books as 'Want to Read' in order for the carousel to appear (works only for today's trending books). A docker-compose restart memcached is needed.

Stakeholders

@mekarpeles

Attribution Disclaimer: By proposing this pull request, I affirm to have made a best-effort and exercised my discretion to make sure relevant sections of this code which substantially leverage code suggestions, code generation, or code snippets from sources (e.g. Stack Overflow, GitHub) have been annotated with basic attribution so reviewers & contributors may have confidence and access to the correct context to evaluate and use this code.

@Philippos01
Copy link
Contributor

Hi @mekarpeles , this is our first implementation of the carouzel. We would like to get some feedback from you in order to make any needed change and finish with the implementation.

@dbouris
Copy link
Contributor Author

dbouris commented May 27, 2022

hi @mekarpeles we checked your reviews. Is there anything else we need to add to this PR?

@mekarpeles mekarpeles marked this pull request as ready for review June 7, 2022 15:26
@mekarpeles mekarpeles self-assigned this Jun 7, 2022
@mekarpeles mekarpeles added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Jun 7, 2022
Copy link
Member

@mekarpeles mekarpeles left a comment

Choose a reason for hiding this comment

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

Refactoring

openlibrary/views/loanstats.py Outdated Show resolved Hide resolved
openlibrary/core/bookshelves.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/views/loanstats.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/api.py Outdated Show resolved Hide resolved
openlibrary/views/loanstats.py Show resolved Hide resolved
@cdrini cdrini force-pushed the 6186/Carousel/Trendings-Books-Carousel branch from 0267ca4 to f75e06c Compare June 8, 2022 20:26
@cdrini cdrini force-pushed the 6186/Carousel/Trendings-Books-Carousel branch from 69b78da to 2e17b3e Compare June 8, 2022 20:32
Copy link
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

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

Lgtm!

If and when we add pagination to the /trending/* pages, we may need to adjust default limits if we see repeated books on each page.

@jimchamp jimchamp merged commit 585f821 into internetarchive:master Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trending Books Carousel
5 participants