-
-
Notifications
You must be signed in to change notification settings - Fork 15
Add docker #513
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
Add docker #513
Conversation
Summary of ChangesHello @seriaati, 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 application's resilience and efficiency by introducing comprehensive error handling for Redis interactions and optimizing database queries for notification checks. It also includes a minor update to provide a custom image asset for a specific character, improving visual consistency. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request, despite its title 'Add docker', introduces several changes unrelated to Docker. It primarily focuses on improving caching logic by handling Redis errors more gracefully and optimizing a database query to resolve an N+1 issue. Additionally, it includes a specific fix for a character's image URL.
My review focuses on further improving the database query optimization and addressing a hardcoded value to enhance maintainability. The changes for Redis error handling are solid.
| await NotesNotify.filter(enabled=True) | ||
| .all() | ||
| .order_by("account__uid") | ||
| .prefetch_related("account") |
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.
This is a good optimization to address an N+1 query problem. However, there is another fetch_related call for account__user and account__user__settings inside the loop on line 624, which introduces another N+1 query. You can solve both with a single prefetch_related call.
By prefetching account__user__settings, you will also fetch the intermediate account and user models, making the fetch_related call on line 624 redundant. You can then remove it for cleaner code.
| .prefetch_related("account") | |
| .prefetch_related("account__user__settings") |
| if character.id == 1211: # Rina | ||
| return "https://r2.img.seria.moe/vLLDhBOYnEjyFWQh.png" |
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.
Using a magic number (1211) and a hardcoded URL makes the code harder to read and maintain. It's better to define these as named constants.
Consider defining them in a relevant constants file (e.g., hoyo_buddy/constants.py) and importing them here. For example:
# In constants.py
RINA_CHARACTER_ID = 1211
RINA_TEAM_BANNER_ICON_URL = "https://r2.img.seria.moe/vLLDhBOYnEjyFWQh.png"
# In this file
if character.id == RINA_CHARACTER_ID: # Rina
return RINA_TEAM_BANNER_ICON_URL
No description provided.