refactor: migrate ingredient aliases/categories to dedicated tables, drop spoonacular_id
- migration 012: create ingredient_categories + ingredient_category_translations tables (7 slugs, Russian names); add ingredient_aliases (ingredient_id, lang, alias) with GIN trigram index; migrate aliases JSONB from ingredient_mappings and ingredient_translations; drop aliases columns and spoonacular_id; add UNIQUE (canonical_name) as conflict key - ingredient/model: remove SpoonacularID, add CategoryName for localized display - ingredient/repository: conflict on canonical_name; GetByID/Search join category translations and aliases lateral; new UpsertAliases (pgx batch), UpsertCategoryTranslation; remove GetBySpoonacularID; split scan helpers into scanMappingWrite / scanMappingRead - gemini/recognition: add IngredientTranslation type; IngredientClassification now carries Translations []IngredientTranslation instead of CanonicalNameRu; update ClassifyIngredient prompt to English with structured translations array - recognition/handler: update ingredientRepo interface; saveClassification uses UpsertAliases and iterates Translations - recipe/model: remove SpoonacularID from RecipeIngredient - integration tests: remove SpoonacularID fixtures, replace GetBySpoonacularID tests with GetByID, add UpsertAliases and UpsertCategoryTranslation tests - Flutter: remove canonicalNameRu from IngredientMapping, add categoryName; displayName returns server-resolved canonicalName; regenerate .g.dart Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
// IngredientMapping is the canonical ingredient record used to link
|
||||
// user products, recipe ingredients, and Spoonacular data.
|
||||
// user products and recipe ingredients.
|
||||
// CanonicalName holds the content for the language resolved at query time
|
||||
// (English by default, or from ingredient_translations when available).
|
||||
type IngredientMapping struct {
|
||||
ID string `json:"id"`
|
||||
CanonicalName string `json:"canonical_name"`
|
||||
SpoonacularID *int `json:"spoonacular_id"`
|
||||
Aliases json.RawMessage `json:"aliases"` // []string
|
||||
Aliases json.RawMessage `json:"aliases"` // []string, populated by read queries
|
||||
Category *string `json:"category"`
|
||||
CategoryName *string `json:"category_name"` // localized category display name
|
||||
DefaultUnit *string `json:"default_unit"`
|
||||
|
||||
CaloriesPer100g *float64 `json:"calories_per_100g"`
|
||||
|
||||
Reference in New Issue
Block a user