Fix Meal Serving Sizing Logic#763
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 a critical bug where meal serving sizes were being incorrectly calculated, leading to inaccurate nutritional tracking. The solution involves restructuring meal handling to consistently track and utilize original meal template data across both the frontend and backend. This ensures that all units (grams, ml, servings) are scaled correctly, preventing erroneous multiplication of base units and providing precise nutritional information when logging or editing meals. 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 correctly addresses a flaw in the meal serving size logic by introducing tracking for the original meal template data. The backend changes to differentiate between template-based and custom meals are solid. However, I've identified a regression on the frontend where the nutrition calculation for custom meals in the food diary is now incorrect. I've also suggested a clarification in another component to improve code readability and maintainability. With these adjustments, the fix will be more robust.
|
Switched to a draft, need further testing at the moment |
|
Also attach screenshot of before vs after fix. |
I put it in the issue itself too: #762 (comment) Example of issue: Take the following: Food item:
Meal:
Additing as a diary entry:Before fix:Scale was multiplying base values by 100 rather than an actual serving. Makes sense when the unit is "serving", but not how it should be handled for quantitative measurements. After Fix:
|
|
Thanks. review once if report charts & table also reflects correctly. |
Those work, but I've come across another issue with handling the scaling. Will put this in draft again for now until it's fixed and fully tested. Likely more tomorrow. |
…e relavent scaling/template id for the defined meal
|
I've done the following tests with the new logic to pull info from backend when editing a template meal:
|




Addresses #762
Restructures the meal handling by tracking the original template meal data, in order to utilize it during the serving logic. Previously, all units (grams, ml, serving) were being treated the same causing in multiplication of the original unit, rather than scaling logic.