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
@@ -104,10 +104,27 @@ model User {
|
||||
fastEvents FastEvent[]
|
||||
mealPlans MealPlan[]
|
||||
deviceTokens DeviceToken[]
|
||||
achievements Achievement[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// PRD §6 — sistema achievement: badge sbloccati man mano che l'utente
|
||||
// raggiunge milestone (prima pesata, primo digiuno, primo piano, ecc.).
|
||||
// `key` identifica univocamente l'achievement (vedi packages/shared).
|
||||
model Achievement {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
key String
|
||||
unlockedAt DateTime @default(now()) @map("unlocked_at")
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, key])
|
||||
@@index([userId])
|
||||
@@map("achievements")
|
||||
}
|
||||
|
||||
// Better Auth — sessione utente firmata.
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
@@ -223,6 +240,9 @@ model Preferences {
|
||||
// PRD §5.1 — pasti/giorno preferiti (1..4). Se null, fallback al default.
|
||||
// Il fastingProtocol ha precedenza: se attivo definisce lui la struttura.
|
||||
mealsPerDay Int? @map("meals_per_day")
|
||||
// PRD §6 — esclusioni granulari per ingredient (override/aggiunte rispetto
|
||||
// ai gruppi exclusionGroups). Memorizzate come array di Ingredient.id.
|
||||
bannedIngredientIds String[] @default([]) @map("banned_ingredient_ids")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
|
||||
Reference in new issue
Block a user