Barcode improvements, App AI Nutrition Label Scan#824
Barcode improvements, App AI Nutrition Label Scan#824CodeWithCJ merged 18 commits intoCodeWithCJ:mainfrom
Conversation
Fix ollama timeout
use quantity instead of servings
Aligned serving quantity logic for adding foods
Updated mobile client for new barcode
Added mention of USDA external AIP
Fix old barcode scan error when returned nutrients is 0 or null
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 introduces a suite of enhancements focused on food data entry and management, particularly for mobile users. It integrates advanced AI capabilities for scanning nutrition labels and significantly upgrades the barcode scanning system by incorporating multiple external data sources and user preferences. Additionally, it bolsters mobile app security by enforcing HTTPS and modernizes the build infrastructure by adopting pnpm, ensuring a more robust and efficient development and user experience. Highlights
Changelog
Ignored Files
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 significant enhancements to barcode scanning and nutrition label processing across the SparkyFitness frontend and backend, alongside general dependency updates and mobile app improvements. Key changes include adding a default_barcode_provider_id preference to user settings, allowing users to select a preferred external service (like USDA or Open Food Facts) for barcode lookups. The mobile app now supports scanning both barcodes and nutrition labels, with a new UI for switching between modes and handling cases where barcodes are not found. The backend is updated to support USDA barcode lookups, normalize barcode formats, and integrate with AI services for nutrition label extraction from images. Additionally, the mobile app enforces HTTPS for API connections in production environments, updates several React Native dependencies, and refactors food entry quantity controls for better user experience. Review comments suggest improving error messages for HTTPS enforcement, ensuring nutriments are checked before destructuring, and considering schema validation for AI-parsed nutrition data.
| .replace(/^```(?:json)?\n?/, "") | ||
| .replace(/\n?```$/, ""); | ||
|
|
||
| const nutrition = JSON.parse(content); |
There was a problem hiding this comment.
Consider adding a validation step to ensure that the parsed JSON object conforms to the expected schema (e.g., using a schema validation library) before returning it. This can help prevent unexpected errors due to malformed or incomplete data.
| const nutrition = JSON.parse(content); | |
| const nutrition = JSON.parse(content); // Consider validating the schema here | |
| return { success: true, nutrition }; |
There was a problem hiding this comment.
Gemini's solution to a nonproblem is to post a todo comment lol
|
@apedley This file has some conflicts. Could you check it out. |
Got it. Was one of the lint comments simsat cleaned up |
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
Related Issue
PR type [x] Issue [x] New Feature [ ] Documentation
Linked Issue: #658
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]