fix for missing custom nutrient when a food item is added to diary#900
fix for missing custom nutrient when a food item is added to diary#900CodeWithCJ merged 2 commits intomainfrom
Conversation
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 resolves an issue where custom nutrients were not consistently appearing across the application, specifically when added to a diary or when setting user goals. The changes ensure that custom nutrient data is properly propagated to relevant database tables upon creation and that the frontend cache is refreshed, leading to a more reliable and consistent user experience. Highlights
Changelog
Activity
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 a fix for custom nutrients not appearing correctly when a food item is added to the diary. The changes are comprehensive, addressing the issue on both the frontend and backend.
On the backend, new custom nutrients are now correctly propagated to goal_presets and user_goals, ensuring they are available for goal tracking. The logic for handling custom_nutrients when creating a food entry has also been made more robust.
On the frontend, query invalidation has been improved in the custom nutrient management hooks to ensure the UI reflects changes to nutrient preferences.
The changes look good and should resolve the issue. I've added a few suggestions to improve consistency in the frontend hooks.
| onSuccess: () => { | ||
| queryClient.invalidateQueries({ | ||
| queryKey: ['preferences', 'nutrients'], | ||
| }); | ||
| return queryClient.invalidateQueries({ | ||
| queryKey: customNutrientsKeys.all, | ||
| }); |
There was a problem hiding this comment.
Similar to the other mutations in this file, the onSuccess handler here has an inconsistent return. It's clearer to call both invalidations without returning a value.
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: ['preferences', 'nutrients'],
});
queryClient.invalidateQueries({
queryKey: customNutrientsKeys.all,
});
},
Tip
Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run
pnpm run validateto check for any errors.PRs that include tests and clear screenshots are highly preferred!
Description
Provide a brief summary of your changes.
Related Issue
PR type [x] Issue [ ] New Feature [ ] Documentation
Linked Issue: #
Checklist
Please check all that apply:
pnpm run validate(especially for Frontend).en) translation file (if applicable).rls_policies.sqlfor any new user-specific tables.Screenshots (if applicable)
Before
[Insert screenshot/GIF here]
After
[Insert screenshot/GIF here]