Fix overlapping nutrition source totals - #2220
Conversation
Preserve provider rows while selecting one canonical contribution set at query time. Ambiguous overlaps return explicit provenance instead of double-counted totals. Refs #2059
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (66)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideImplements canonical per-day nutrition source resolution backed by new PostgreSQL views and enums, routes all serving paths (server, web, mobile, Slack, MCP, analytics, export) through these canonical totals with explicit provenance, and surfaces overlapping-source conflicts instead of double-counting while preserving raw provider data. Sequence diagram for nutrition by date conflict-aware responsesequenceDiagram
actor User
participant WebClient
participant FoodRouter as foodRouter.byDate
participant FoodRepo as FoodRepository
participant SettingsRepo as SettingsRepository
participant CanonicalDaily as fitness.v_nutrition_canonical_daily
User->>WebClient: Request nutrition for date
WebClient->>FoodRouter: byDate(date)
FoodRouter->>SettingsRepo: getCalorieGoal()
SettingsRepo-->>FoodRouter: calorieGoal
FoodRouter->>FoodRepo: nutritionByDate(date, calorieGoal)
FoodRepo->>CanonicalDaily: SELECT ... FROM v_nutrition_canonical_daily
CanonicalDaily-->>FoodRepo: row(resolution_status,...)
alt resolution_status == available
FoodRepo-->>FoodRouter: {summary, resolution}
else resolution_status == source_conflict
FoodRepo-->>FoodRouter: {summary: null, resolution}
end
FoodRouter-->>WebClient: {entries, summary, resolution}
alt status == available
WebClient-->>User: Show totals and macros
else status == source_conflict
WebClient-->>User: Show conflict alert, hide totals
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoResolve overlapping nutrition sources via canonical daily contribution views
AI Description
Diagram
High-Level Assessment
Files changed (50)
|
Mobile PreviewScan to open on device:
To test on device:
|
|
Storybook previews for This comment updates automatically on each PR push. |
Retain v_nutrition_daily as the serving contract and rename the raw provider projection to v_nutrition_provider_daily. Format migration 0059 for the strict SQLFluff gate. Refs #2059
Summary of ReviewThis PR introduces a well-structured canonical nutrition contribution set that resolves provider overlap, handles itemized vs. aggregate food entry grains, and cleanly surfaces resolution statuses to consumers. Key Findings:
Both issues have inline suggestions attached. Overall, the schema, resolution logic, and mobile/web UI additions look clean and well-tested! 🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does. |
Code Review by Qodo
Context used✅ Compliance rules (platform):
251 rules✅ Skills:
fix-provider, write-tests, cloudflare 1.
|
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
…sue-2059 # Conflicts: # docs/production-incident-baseline.md # drizzle/meta/_journal.json
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Summary
fitness.v_nutrition_dailyas the canonical one-row-per-user/date serving contract, resolving a single contribution set or an explicit source conflictfood.byDatev1 DTO and fail conflicts with an actionable precondition errorfood.byDateV2for conflict-aware web/mobile clients and version the mobile persisted-query contract so stale v1 data is discardedfitness.v_nutrition_provider_dailyfor provider detail, statistics, and exportsValidation
no space left on device)Closes #2059