Fix email timing and show fallback data when Garmin sync pending
All checks were successful
Deploy / deploy (push) Successful in 2m31s

- Add 15-minute notification granularity (*/15 cron) so users get emails
  at their configured time instead of rounding to the nearest hour
- Add DailyLog fallback to most recent when today's log doesn't exist,
  preventing 100/100/Unknown default values before morning sync
- Show "Last synced" indicator when displaying stale data
- Change Garmin sync to 6-hour intervals (0,6,12,18 UTC) to ensure
  data is available before European morning notifications

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 09:56:41 +00:00
parent 0d5785aaaa
commit 092d8bb3dd
7 changed files with 402 additions and 31 deletions

View File

@@ -43,20 +43,21 @@ export async function register() {
}
}
// Schedule notifications at the top of every hour
cron.default.schedule("0 * * * *", () => {
// Schedule notifications every 15 minutes for finer-grained delivery times
cron.default.schedule("*/15 * * * *", () => {
console.log("[cron] Triggering notifications...");
triggerCronEndpoint("notifications", "Notifications");
});
// Schedule Garmin sync 3 times daily (8 AM, 2 PM, 10 PM UTC)
cron.default.schedule("0 8,14,22 * * *", () => {
// Schedule Garmin sync 4 times daily (every 6 hours) to ensure data is available
// before European morning notifications
cron.default.schedule("0 0,6,12,18 * * *", () => {
console.log("[cron] Triggering Garmin sync...");
triggerCronEndpoint("garmin-sync", "Garmin sync");
});
console.log(
"[cron] Scheduler started - notifications hourly, Garmin sync at 08:00/14:00/22:00 UTC",
"[cron] Scheduler started - notifications every 15 min, Garmin sync at 00:00/06:00/12:00/18:00 UTC",
);
}
}