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:
@@ -7,8 +7,8 @@ class IngredientMapping {
|
||||
final String id;
|
||||
@JsonKey(name: 'canonical_name')
|
||||
final String canonicalName;
|
||||
@JsonKey(name: 'canonical_name_ru')
|
||||
final String? canonicalNameRu;
|
||||
@JsonKey(name: 'category_name')
|
||||
final String? categoryName;
|
||||
final String? category;
|
||||
@JsonKey(name: 'default_unit')
|
||||
final String? defaultUnit;
|
||||
@@ -18,14 +18,14 @@ class IngredientMapping {
|
||||
const IngredientMapping({
|
||||
required this.id,
|
||||
required this.canonicalName,
|
||||
this.canonicalNameRu,
|
||||
this.categoryName,
|
||||
this.category,
|
||||
this.defaultUnit,
|
||||
this.storageDays,
|
||||
});
|
||||
|
||||
/// Display name prefers Russian, falls back to canonical English name.
|
||||
String get displayName => canonicalNameRu ?? canonicalName;
|
||||
/// Display name is the server-resolved canonical name (language-aware from backend).
|
||||
String get displayName => canonicalName;
|
||||
|
||||
factory IngredientMapping.fromJson(Map<String, dynamic> json) =>
|
||||
_$IngredientMappingFromJson(json);
|
||||
|
||||
Reference in New Issue
Block a user