Add day-of and crock-pot start-by reminders (Feature 20)
CI / ci (push) Successful in 7m39s
CI / ci (pull_request) Successful in 7m24s

Register plan.Service.ReminderSchedules as the day_of_reminder schedule:
daily at the household reminder_time (period YYYY-MM-DD) it emits
day_of_reminder:YYYY-MM-DD, "Tonight: {dinner} · Recipe →" linking
/dinner/{id}; for a crock-pot dinner whose start_by is earlier than
reminder_time it also fires 15 minutes before start_by (period
start:YYYY-MM-DD) and emits day_of_reminder:start:YYYY-MM-DD, "Start the
crock pot by {time}". A date whose week has no plan emits nothing.

The scheduler gains DailyAt rules, whose fire time per date is looked up
from data on every pass (a failed lookup is retried every ClaimRetry),
and a Schedule Key that prefixes period keys so two schedules of one
name claim different periods.

Maestro task 30963b62-2803-4879-82ff-c351cc6628cf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 12:51:54 -04:00
co-authored by Claude Opus 5.5
parent 15860fbbaf
commit a7a56623e5
9 changed files with 660 additions and 74 deletions
+22 -3
View File
@@ -65,12 +65,27 @@ func ListReady(week store.LocalDate, needed, dinners int) notify.Event {
}
// DayOfReminder is the day_of_reminder event of the dinner dinnerID, named
// name, planned on date.
// name, planned on date: "Tonight: Tacos · Recipe →", a title carrying its
// own call to action.
func DayOfReminder(date store.LocalDate, dinnerID, name string) notify.Event {
return notify.Event{
Type: notify.DayOfReminder,
Key: string(notify.DayOfReminder) + ":" + date.String(),
Title: "Tonight's dinner",
Title: "Tonight: " + name + " · Recipe →",
URL: "/dinner/" + dinnerID,
Week: household.WeekStart(date),
}
}
// StartReminder is the day_of_reminder event, keyed
// day_of_reminder:start:{date}, reminding the household to start the
// crock-pot dinner dinnerID, named name and planned on date, by startBy,
// a time in the household zone: "Start the crock pot by 9:30 am".
func StartReminder(date store.LocalDate, dinnerID, name string, startBy time.Time) notify.Event {
return notify.Event{
Type: notify.DayOfReminder,
Key: string(notify.DayOfReminder) + ":start:" + date.String(),
Title: "Start the crock pot by " + startBy.Format("3:04 pm"),
Body: name,
URL: "/dinner/" + dinnerID,
Week: household.WeekStart(date),
@@ -173,9 +188,13 @@ func planTitle(week, thisWeek store.LocalDate) string {
}
// Text is the Google Chat message of p: its title, its body after a colon
// and the event's call to action with an arrow.
// and the event's call to action with an arrow. A title ending in an arrow,
// with no body, carries its own call to action and is the message as it is.
func Text(p notify.Payload) string {
text := p.Title
if p.Body == "" && strings.HasSuffix(text, "→") {
return text
}
if p.Body != "" {
if endsSentence(text) {
text += " "
+14 -3
View File
@@ -2,6 +2,7 @@ package chat
import (
"testing"
"time"
"code.cubecraftlabs.com/Maniacs_Mansion/Meal-Quest/internal/notify"
"code.cubecraftlabs.com/Maniacs_Mansion/Meal-Quest/internal/store"
@@ -100,9 +101,19 @@ func TestMessages(t *testing.T) {
key: "day_of_reminder:2026-10-15",
url: "/dinner/01J9Z8Y7X6W5V4T3S2R1Q0P9N8",
week: "2026-10-12",
title: "Tonight's dinner",
body: "Tacos",
chatT: "Tonight's dinner: Tacos. Open the recipe →",
title: "Tonight: Tacos · Recipe →",
body: "",
chatT: "Tonight: Tacos · Recipe →",
},
{
name: "crock-pot start reminder",
ev: StartReminder(mustDate(t, "2026-10-15"), "01J9Z8Y7X6W5V4T3S2R1Q0P9N8", "Beef Chili", time.Date(2026, 10, 15, 9, 30, 0, 0, time.FixedZone("CDT", -5*60*60))),
key: "day_of_reminder:start:2026-10-15",
url: "/dinner/01J9Z8Y7X6W5V4T3S2R1Q0P9N8",
week: "2026-10-12",
title: "Start the crock pot by 9:30 am",
body: "Beef Chili",
chatT: "Start the crock pot by 9:30 am: Beef Chili. Open the recipe →",
},
{
name: "new suggestions",