feat: §6 Gruppo B residuo — pannello macros, esclusioni granulari, achievement
- Plan: pannello macros laterale "oggi" con consumati/pianificati vs target (kcal/P/F/C). Sticky su lg, in-flow su mobile. Profile/derived ora include kcalTarget e i macro target (BMR aggiustato per condizioni e diet history). - Preferenze: nuova sezione "Ingredienti specifici da evitare" con ricerca debounced sul catalogo (cap 50). Schema Preferences.bannedIngredientIds + matchmaking che scarta ricette contenenti ingredient bandito (test unit). - Achievement: tabella Achievement (userId+key unique), 4 traguardi iniziali (first_weigh_in, first_plan, first_fast_complete, ten_meals_consumed). Service idempotente eval+persist agganciato a 4 trigger (weight POST, plan POST, fast PATCH→COMPLETED, slot consumed). Push notification best-effort all'unlock. Pannello badge nel profilo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3b895191f5
commit
d17c5ef869
29 files changed
+1048
-86
No files matched your search
@@ -15,6 +15,9 @@ export interface RecipeCandidate {
|
||||
fatG: number;
|
||||
netCarbG: number;
|
||||
exclusionTags: ReadonlyArray<string>;
|
||||
// PRD §6 — ingredient ids della ricetta. Usati per applicare le esclusioni
|
||||
// granulari per singolo ingrediente (`bannedIngredientIds`).
|
||||
ingredientIds?: ReadonlyArray<string>;
|
||||
phases: ReadonlyArray<1 | 2 | 3>;
|
||||
prepMinutes?: number;
|
||||
}
|
||||
@@ -31,6 +34,9 @@ export interface MatchOptions {
|
||||
meal: RecipeCandidate['category'];
|
||||
phase: 1 | 2 | 3;
|
||||
excludedTags: ReadonlyArray<string>;
|
||||
// PRD §6 — ids di Ingredient che l'utente ha bandito espressamente.
|
||||
// Una ricetta è scartata se contiene almeno uno di questi ingredients.
|
||||
bannedIngredientIds?: ReadonlyArray<string>;
|
||||
recentlyConsumedIds?: ReadonlyArray<string>;
|
||||
// Macros già consumati nello stesso giorno; usati per bilanciare le scelte
|
||||
// successive (la cena tiene conto di colazione/pranzo/spuntino).
|
||||
@@ -74,6 +80,7 @@ export function matchMeals(opts: MatchOptions): MatchResult[] {
|
||||
|
||||
const recentSet = new Set(opts.recentlyConsumedIds ?? []);
|
||||
const exclusionSet = new Set(opts.excludedTags);
|
||||
const bannedSet = new Set(opts.bannedIngredientIds ?? []);
|
||||
|
||||
const results: MatchResult[] = [];
|
||||
|
||||
@@ -81,6 +88,8 @@ export function matchMeals(opts: MatchOptions): MatchResult[] {
|
||||
if (r.category !== opts.meal) continue;
|
||||
if (!r.phases.includes(opts.phase)) continue;
|
||||
if (r.exclusionTags.some((tag) => exclusionSet.has(tag))) continue;
|
||||
if (bannedSet.size > 0 && r.ingredientIds && r.ingredientIds.some((id) => bannedSet.has(id)))
|
||||
continue;
|
||||
|
||||
const dKcal = (r.kcal - mealTarget.kcal) / Math.max(1, mealTarget.kcal);
|
||||
const dPro = (r.proteinG - mealTarget.proteinG) / Math.max(1, mealTarget.proteinG);
|
||||
|
||||
Reference in new issue
Block a user