Conversation
… of books per author in related book recommendations
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bookdb-landing | 0f5d6a4 | Commit Preview URL Branch Preview URL |
Mar 12 2026, 10:22 AM |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the book recommendation system by introducing author diversification. The primary goal is to prevent search results or related book suggestions from being dominated by a single author, thereby offering users a broader range of choices. This is achieved by fetching more candidates than initially required, applying a new diversification algorithm that limits books per author, and ensuring this logic is consistently applied across both primary and fallback recommendation paths. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces book diversification by author to the related books feature. A new helper function _diversify_books_by_author is added, and the get_related_books endpoint is updated to use it, both for Qdrant results and the popular books fallback. The changes look good overall, but I've found a performance issue with the caching logic in get_related_books where the cache is being ignored. I've also included a couple of suggestions to improve code clarity and conciseness.
| cached_ids = _qdrant_cache.get(goodreads_id) | ||
| recent_failure = _qdrant_failure_cache.get(goodreads_id, False) | ||
|
|
||
| if cached_ids is not None: | ||
| related = load_books_by_goodreads_ids(db, cached_ids) | ||
| return serialize_books_with_engagement(db, related) | ||
|
|
||
| # Skip cached results - they don't have diversification applied | ||
| # Let them naturally expire (30 min TTL) |
There was a problem hiding this comment.
The caching logic for Qdrant results appears to be ineffective. cached_ids are fetched from the cache on line 631 but are then ignored. The code proceeds to call most_similar on every request, bypassing the cache. This negates the benefit of caching, increasing latency and load on the Qdrant service.
To fix this, you should use the cached_ids if they exist, and only query Qdrant if there's a cache miss. The misleading comment on lines 634-635 should also be removed or updated.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Changes:
Added _diversify_books_by_author() helper function in books router
Modified get_related_books() endpoint
Added configuration constants
Closes #142