- Rename catalog: ingredient/* → product/* (canonical_name, barcode, nutrition per 100g)
- Rename pantry: product/* → userproduct/* (user-owned items with expiry)
- Squash migrations into single 001_initial_schema.sql (clean-db baseline)
- product_categories: add English canonical name column; fix COALESCE in queries
- Remove product_translations: product names are stored in their original language
- Add default_unit_name to product API responses via unit_translations JOIN
- Add cmd/importoff: bulk import from OpenFoodFacts JSONL dump (COPY + ON CONFLICT)
- Diary: support product_id entries alongside dish_id (CHECK num_nonnulls = 1)
- Home: getLoggedCalories joins both recipes and catalog products
- Flutter: rename models/providers/services to match backend rename
- Flutter: add barcode scan flow for diary (mobile_scanner, product_portion_sheet)
- Flutter: localise 6 new keys across 12 languages (barcode scan, portion weight)
- Routes: GET /products/search, GET /products/barcode/{barcode}, /user-products
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package diary
|
|
|
|
import "time"
|
|
|
|
// Entry is a single meal diary record.
|
|
type Entry struct {
|
|
ID string `json:"id"`
|
|
Date string `json:"date"` // YYYY-MM-DD
|
|
MealType string `json:"meal_type"`
|
|
Name string `json:"name"` // from dishes or products JOIN
|
|
Portions float64 `json:"portions"`
|
|
Calories *float64 `json:"calories,omitempty"` // recipe.calories_per_serving * portions, or product * portion_g
|
|
ProteinG *float64 `json:"protein_g,omitempty"`
|
|
FatG *float64 `json:"fat_g,omitempty"`
|
|
CarbsG *float64 `json:"carbs_g,omitempty"`
|
|
Source string `json:"source"`
|
|
DishID *string `json:"dish_id,omitempty"`
|
|
ProductID *string `json:"product_id,omitempty"`
|
|
RecipeID *string `json:"recipe_id,omitempty"`
|
|
PortionG *float64 `json:"portion_g,omitempty"`
|
|
JobID *string `json:"job_id,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// CreateRequest is the body for POST /diary.
|
|
type CreateRequest struct {
|
|
Date string `json:"date"`
|
|
MealType string `json:"meal_type"`
|
|
Name string `json:"name"` // input-only; used if DishID is nil and ProductID is nil
|
|
Portions float64 `json:"portions"`
|
|
Source string `json:"source"`
|
|
DishID *string `json:"dish_id"`
|
|
ProductID *string `json:"product_id"`
|
|
RecipeID *string `json:"recipe_id"`
|
|
PortionG *float64 `json:"portion_g"`
|
|
JobID *string `json:"job_id"`
|
|
}
|