fix for auto scale issue in food variants#815
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 addresses an issue where custom food variant nutrients were not correctly auto-scaling when the serving size was adjusted. The changes ensure that both standard and custom nutrient fields are properly identified and scaled proportionally, and that manual edits to any nutrient field or serving size correctly update the baseline for future calculations, leading to more accurate food tracking. 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 addresses an issue with auto-scaling food variants, specifically for custom nutrients. The changes introduce logic to correctly scale custom nutrients when the serving size is adjusted on a locked variant. Additionally, the code has been refactored to improve readability by extracting the check for custom nutrients into a variable, and a redundant declaration of nutrientFields has been removed. The logic for updating the baseline values for scaling after a manual edit has also been improved to be more robust, using a deep copy of the entire variant. The implementation appears correct and effectively resolves the reported issue.
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: # #801
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]