feat: batch-cook shopping list (already worked) + leftover expiry reminders
Shopping list add already worked generically for batch-cook recipes — no code needed there. New: mark a specific batch-cook dish as "cooked today", track its fridge expiry (cookingHistory.batchDishId), surface a "Leftovers expiring soon" widget on the pantry page, and send a daily push+email reminder via a new /api/internal/cron/leftover-reminders endpoint (mirrors the weekly-digest cron pattern; doesn't use the social notifications table, which requires a non-null actor and isn't built for self-reminders). Also fixes, from user-reported bugs: - Recipe cards showed no batch-cook badge/dish-count/prep-time in some views — added dishCount + prepMins/cookMins (now generated by the AI and persisted) to the card component and /recipes query. - Batch-cook descriptions occasionally contained raw markdown (**bold**) — added explicit "plain prose only" prompt instructions and a stripMarkdown() defensive fallback at render time. - Truncated/cut-off descriptions — the generateObject call had no maxOutputTokens set, so long structured responses could get cut off mid-field; now capped explicitly at 8000. - Generate dialogs (batch-cook + the main AI dialog) could show buttons unreachable once the progress bar appeared mid-generation — restructured so the action row is pinned outside the scrollable content area, not affected by content height changes. - /api/internal/* routes were being redirected to /login by middleware before their own CRON_SECRET check ever ran (pre-existing bug, affected the weekly-digest cron too) — added to PUBLIC_PATHS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE "cooking_history" ADD COLUMN "batch_dish_id" text;--> statement-breakpoint
|
||||
ALTER TABLE "cooking_history" ADD COLUMN "expiry_reminder_sent_at" timestamp;--> statement-breakpoint
|
||||
ALTER TABLE "cooking_history" ADD CONSTRAINT "cooking_history_batch_dish_id_recipe_batch_dishes_id_fk" FOREIGN KEY ("batch_dish_id") REFERENCES "public"."recipe_batch_dishes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "cooking_history_batch_dish_idx" ON "cooking_history" USING btree ("batch_dish_id");
|
||||
File diff suppressed because it is too large
Load Diff
@@ -218,6 +218,13 @@
|
||||
"when": 1783814978348,
|
||||
"tag": "0030_kind_lightspeed",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 31,
|
||||
"version": "7",
|
||||
"when": 1783841772890,
|
||||
"tag": "0031_brave_arclight",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { relations } from "drizzle-orm";
|
||||
import { users } from "./users";
|
||||
import { recipes } from "./recipes";
|
||||
import { recipes, recipeBatchDishes } from "./recipes";
|
||||
|
||||
export const notificationTypeEnum = pgEnum("notification_type", [
|
||||
"follow",
|
||||
@@ -87,11 +87,14 @@ export const cookingHistory = pgTable("cooking_history", {
|
||||
id: text("id").primaryKey(),
|
||||
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
recipeId: text("recipe_id").notNull().references(() => recipes.id, { onDelete: "cascade" }),
|
||||
batchDishId: text("batch_dish_id").references(() => recipeBatchDishes.id, { onDelete: "cascade" }),
|
||||
cookedAt: timestamp("cooked_at").notNull().defaultNow(),
|
||||
servings: integer("servings"),
|
||||
notes: text("notes"),
|
||||
expiryReminderSentAt: timestamp("expiry_reminder_sent_at"),
|
||||
}, (t) => [
|
||||
index("cooking_history_user_idx").on(t.userId),
|
||||
index("cooking_history_batch_dish_idx").on(t.batchDishId),
|
||||
]);
|
||||
|
||||
export const notifications = pgTable("notifications", {
|
||||
@@ -111,6 +114,7 @@ export const notifications = pgTable("notifications", {
|
||||
export const cookingHistoryRelations = relations(cookingHistory, ({ one }) => ({
|
||||
user: one(users, { fields: [cookingHistory.userId], references: [users.id] }),
|
||||
recipe: one(recipes, { fields: [cookingHistory.recipeId], references: [recipes.id] }),
|
||||
batchDish: one(recipeBatchDishes, { fields: [cookingHistory.batchDishId], references: [recipeBatchDishes.id] }),
|
||||
}));
|
||||
|
||||
export const notificationsRelations = relations(notifications, ({ one }) => ({
|
||||
|
||||
Reference in New Issue
Block a user