diff --git a/src/app/api/today/route.ts b/src/app/api/today/route.ts index ae2a344..5d2eb75 100644 --- a/src/app/api/today/route.ts +++ b/src/app/api/today/route.ts @@ -71,12 +71,15 @@ export const GET = withAuth(async (_request, user, pb) => { } // Try to fetch today's DailyLog for biometrics + // Sort by created DESC to get the most recent record if multiple exist let biometrics = { ...DEFAULT_BIOMETRICS, phaseLimit }; try { const today = new Date().toISOString().split("T")[0]; const dailyLog = await pb .collection("dailyLogs") - .getFirstListItem(`user="${user.id}" && date~"${today}"`); + .getFirstListItem(`user="${user.id}" && date~"${today}"`, { + sort: "-created", + }); biometrics = { hrvStatus: dailyLog.hrvStatus,