Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(dashboard): compute current and 12-month best goal streaks

Khuram Niaz241e1ecb4d03
diff --git a/__tests__/DailyGoalsCalendar.spec.tsx b/__tests__/DailyGoalsCalendar.spec.tsx
index beb3c48..02bbe6a 100644
--- a/__tests__/DailyGoalsCalendar.spec.tsx
+++ b/__tests__/DailyGoalsCalendar.spec.tsx
@@ -30,6 +30,7 @@ describe("DailyGoalsCalendar", () => {
values: { "2026-10-01": { jobs: 3, hours: 2.5 } },
targets,
}}
+ initialStreaks={{ current: 2, best: 11 }}
/>,
);
const ok = (values: object = {}, targets: object = {}) => ({
@@ -137,12 +138,30 @@ describe("DailyGoalsCalendar", () => {
summary().getAllByRole(role).map((el) => el.textContent);
expect(text("term")).toEqual([
"Current streak",
- "Best streak",
+ "Best streak (12 mo)",
"Both goals met",
"Nothing logged",
]);
- // Placeholder streaks, then Oct 2–4 with nothing logged
- expect(text("definition")).toEqual(["3 days", "7 days", "0 days", "3 days"]);
+ // Streaks from the server, then Oct 2–4 with nothing logged
+ expect(text("definition")).toEqual(["2 days", "11 days", "0 days", "3 days"]);
+ });
+
+ it("shows the same streaks on an earlier month", async () => {
+ (getDailyGoalValues as any).mockResolvedValue(ok());
+ renderCalendar();
+ await user.click(previous());
+ expect(await summary().findByText("11 days")).toBeInTheDocument();
+ });
+
+ it("shows dashes when streaks failed to load", () => {
+ render(
+ <DailyGoalsCalendar
+ today={today}
+ initialData={{ values: {}, targets: {} }}
+ initialStreaks={null}
+ />,
+ );
+ expect(summary().getAllByText("—")).toHaveLength(2);
});
it("moves the calendar when the summary navigates", async () => {
@@ -194,7 +213,13 @@ describe("DailyGoalsCalendar", () => {
});
it("shows no summary when the current month failed to load", () => {
- render(<DailyGoalsCalendar today={today} initialData={null} />);
+ render(
+ <DailyGoalsCalendar
+ today={today}
+ initialData={null}
+ initialStreaks={null}
+ />,
+ );
expect(
summary().getByText("October 2026. Goal hit: no data"),
).toBeInTheDocument();
diff --git a/__tests__/dailyGoals.actions.spec.ts b/__tests__/dailyGoals.actions.spec.ts
index 26572b6..c26d6f7 100644
--- a/__tests__/dailyGoals.actions.spec.ts
+++ b/__tests__/dailyGoals.actions.spec.ts
@@ -1,5 +1,6 @@
import {
getDailyGoalValues,
+ getGoalStreaks,
updateGoalTargets,
} from "@/actions/dailyGoals.actions";
import { getCurrentUser } from "@/utils/user.utils";
@@ -239,9 +240,94 @@ describe("updateGoalTargets", () => {
expect(prisma.userSettings.upsert).not.toHaveBeenCalled();
});
+ it("returns fresh streaks judged against the new targets", async () => {
+ (prisma.job.groupBy as any).mockResolvedValue([
+ { appliedDate: new Date(2026, 9, 5, 9), _count: { _all: 3 } },
+ ]);
+ (prisma.activity.findMany as any).mockResolvedValue([
+ { startTime: new Date(2026, 9, 5, 10), duration: 360 },
+ ]);
+ const result = await updateGoalTargets({ month: "2026-10", jobs: 3, hours: 6 });
+ expect(result).toEqual({
+ success: true,
+ data: {
+ targets: { "2026-10": { jobs: 3, hours: 6 } },
+ streaks: { current: 1, best: 1 },
+ },
+ });
+ });
+
+ it("still reports the save when the recount fails", async () => {
+ (prisma.activity.findMany as any).mockRejectedValue(new Error("busy"));
+ const result = await updateGoalTargets({ month: "2026-10", jobs: 3, hours: 6 });
+ expect(result).toEqual({
+ success: true,
+ data: { targets: { "2026-10": { jobs: 3, hours: 6 } }, streaks: null },
+ });
+ });
+
it("returns a failure when not signed in", async () => {
(getCurrentUser as any).mockResolvedValue(null);
const result = await updateGoalTargets({ month: "2026-10", jobs: 3, hours: 6 });
expect(result).toEqual({ success: false, message: "Not authenticated" });
});
});
+
+describe("getGoalStreaks", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date(2026, 9, 5, 12));
+ (getCurrentUser as any).mockResolvedValue({ id: "user-id" });
+ (prisma.userSettings.findUnique as any).mockResolvedValue(null);
+ (prisma.job.groupBy as any).mockResolvedValue([]);
+ (prisma.activity.findMany as any).mockResolvedValue([]);
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it("scans the 12-month window through today for the user", async () => {
+ await getGoalStreaks();
+ const range = {
+ gte: new Date(2025, 10, 1, 0, 0, 0, 0),
+ lte: new Date(2026, 9, 5, 23, 59, 59, 999),
+ };
+ expect(prisma.job.groupBy).toHaveBeenCalledWith(
+ expect.objectContaining({
+ where: { userId: "user-id", applied: true, appliedDate: range },
+ }),
+ );
+ expect(prisma.activity.findMany).toHaveBeenCalledWith(
+ expect.objectContaining({
+ where: { userId: "user-id", startTime: range, duration: { not: null } },
+ }),
+ );
+ });
+
+ it("judges days against the stored targets", async () => {
+ (prisma.userSettings.findUnique as any).mockResolvedValue({
+ settings: JSON.stringify({ goals: { targets: { "2026-10": { jobs: 1, hours: 1 } } } }),
+ });
+ (prisma.job.groupBy as any).mockResolvedValue([
+ { appliedDate: new Date(2026, 9, 4, 9), _count: { _all: 1 } },
+ { appliedDate: new Date(2026, 9, 5, 9), _count: { _all: 1 } },
+ ]);
+ (prisma.activity.findMany as any).mockResolvedValue([
+ { startTime: new Date(2026, 9, 4, 10), duration: 60 },
+ { startTime: new Date(2026, 9, 5, 10), duration: 60 },
+ ]);
+ expect(await getGoalStreaks()).toEqual({
+ success: true,
+ data: { current: 2, best: 2 },
+ });
+ });
+
+ it("returns a failure when not signed in", async () => {
+ (getCurrentUser as any).mockResolvedValue(null);
+ expect(await getGoalStreaks()).toEqual({
+ success: false,
+ message: "Not authenticated",
+ });
+ });
+});
diff --git a/__tests__/dailyGoals.spec.ts b/__tests__/dailyGoals.spec.ts
index 044e198..da84d11 100644
--- a/__tests__/dailyGoals.spec.ts
+++ b/__tests__/dailyGoals.spec.ts
@@ -1,8 +1,9 @@
-import { DAILY_GOALS } from "@/lib/constants";
+import { format } from "date-fns";
import {
DEFAULT_GOAL_TARGETS,
buildGoalValues,
buildMonthSummary,
+ findStreaks,
formatDays,
goalMonthRange,
isValidMonth,
@@ -105,6 +106,7 @@ describe("dailyGoals helpers", () => {
},
"2026-10-05",
T,
+ null,
);
expect(summary.rings).toEqual({ jobs: 2 / 30, hours: 2 / 30 });
expect(stat(summary, "Both goals met")).toBe("1 day");
@@ -117,6 +119,7 @@ describe("dailyGoals helpers", () => {
{ "2026-09-01": { jobs: 9, hours: 3.9 } },
"2026-10-05",
T,
+ null,
);
expect(summary.rings).toEqual({ jobs: 1 / 30, hours: 0 });
});
@@ -127,6 +130,7 @@ describe("dailyGoals helpers", () => {
{ "2026-10-01": met, "2026-10-20": met },
"2026-10-05",
T,
+ null,
);
// Oct 1–4 past, today not met
expect(summary.rings).toEqual({ jobs: 1 / 4, hours: 1 / 4 });
@@ -140,6 +144,7 @@ describe("dailyGoals helpers", () => {
{ "2026-10-05": { jobs: 5, hours: 1 } },
"2026-10-05",
T,
+ null,
);
expect(summary.rings).toEqual({ jobs: 1 / 5, hours: 0 / 4 });
expect(stat(summary, "Both goals met")).toBe("0 days");
@@ -151,18 +156,19 @@ describe("dailyGoals helpers", () => {
{ "2026-10-05": met },
"2026-10-05",
T,
+ null,
);
expect(summary.rings).toEqual({ jobs: 1 / 5, hours: 1 / 5 });
expect(stat(summary, "Both goals met")).toBe("1 day");
});
it("never counts today as nothing logged", () => {
- const summary = buildMonthSummary("2026-10", {}, "2026-10-05", T);
+ const summary = buildMonthSummary("2026-10", {}, "2026-10-05", T, null);
expect(stat(summary, "Nothing logged")).toBe("4 days");
});
it("first of the month with nothing met has no ring values", () => {
- const summary = buildMonthSummary("2026-10", {}, "2026-10-01", T);
+ const summary = buildMonthSummary("2026-10", {}, "2026-10-01", T, null);
expect(summary.rings).toEqual({});
expect(stat(summary, "Both goals met")).toBe("0 days");
expect(stat(summary, "Nothing logged")).toBe("0 days");
@@ -170,15 +176,15 @@ describe("dailyGoals helpers", () => {
it("uses the real month length", () => {
expect(
- stat(buildMonthSummary("2024-02", {}, "2026-10-05", T), "Nothing logged"),
+ stat(buildMonthSummary("2024-02", {}, "2026-10-05", T, null), "Nothing logged"),
).toBe("29 days");
expect(
- stat(buildMonthSummary("2026-02", {}, "2026-10-05", T), "Nothing logged"),
+ stat(buildMonthSummary("2026-02", {}, "2026-10-05", T, null), "Nothing logged"),
).toBe("28 days");
});
it("shows real zeros for a loaded month with no records", () => {
- const summary = buildMonthSummary("2026-08", {}, "2026-10-05", T);
+ const summary = buildMonthSummary("2026-08", {}, "2026-10-05", T, null);
expect(summary.rings).toEqual({ jobs: 0, hours: 0 });
expect(stat(summary, "Nothing logged")).toBe("31 days");
});
@@ -189,34 +195,37 @@ describe("dailyGoals helpers", () => {
{ "2026-09-01": { jobs: 0, hours: 0 }, "2026-09-02": { jobs: 1, hours: 0 } },
"2026-10-05",
T,
+ null,
);
expect(stat(summary, "Nothing logged")).toBe("29 days");
});
- it("lists the four rows in order with placeholder streaks", () => {
- const summary = buildMonthSummary("2026-09", {}, "2026-10-05", T);
+ it("lists the four rows in order with the streaks passed in", () => {
+ const summary = buildMonthSummary("2026-09", {}, "2026-10-05", T, {
+ current: 1,
+ best: 11,
+ });
expect(summary.stats).toEqual([
- {
- label: "Current streak",
- value: formatDays(DAILY_GOALS.PLACEHOLDER_STREAKS.CURRENT),
- tone: "primary",
- },
- {
- label: "Best streak",
- value: formatDays(DAILY_GOALS.PLACEHOLDER_STREAKS.BEST),
- tone: "warning",
- },
+ { label: "Current streak", value: "1 day", tone: "primary" },
+ { label: "Best streak (12 mo)", value: "11 days", tone: "warning" },
{ label: "Both goals met", value: "0 days", tone: "success" },
{ label: "Nothing logged", value: "30 days", tone: "danger" },
]);
});
+ it("shows a dash for streaks that failed to load", () => {
+ const summary = buildMonthSummary("2026-09", {}, "2026-10-05", T, null);
+ expect(stat(summary, "Current streak")).toBe("—");
+ expect(stat(summary, "Best streak (12 mo)")).toBe("—");
+ });
+
it("judges days against the targets passed in", () => {
const summary = buildMonthSummary(
"2026-09",
{ "2026-09-01": { jobs: 3, hours: 2 } },
"2026-10-05",
{ jobs: 3, hours: 2 },
+ null,
);
expect(summary.rings).toEqual({ jobs: 1 / 30, hours: 1 / 30 });
expect(stat(summary, "Both goals met")).toBe("1 day");
@@ -275,4 +284,81 @@ describe("dailyGoals helpers", () => {
).toEqual({ jobs: 2, hours: 1 });
});
});
+
+ describe("findStreaks", () => {
+ const met = { jobs: 5, hours: 4 };
+ // Every day from `from` to `to` inclusive, met at the default targets
+ const days = (from: string, to: string, value = met) => {
+ const out: Record<string, typeof met> = {};
+ const d = new Date(`${from}T00:00:00`);
+ for (; format(d, "yyyy-MM-dd") <= to; d.setDate(d.getDate() + 1)) {
+ out[format(d, "yyyy-MM-dd")] = value;
+ }
+ return out;
+ };
+
+ it("counts both ends of a run across a month boundary", () => {
+ expect(
+ findStreaks(days("2026-09-25", "2026-10-05"), {}, "2025-11-01", "2026-10-05"),
+ ).toEqual({ current: 11, best: 11 });
+ });
+
+ it("an unmet today does not break the run", () => {
+ const values = { ...days("2026-10-01", "2026-10-04"), "2026-10-05": { jobs: 1, hours: 0 } };
+ expect(findStreaks(values, {}, "2025-11-01", "2026-10-05")).toEqual({
+ current: 4,
+ best: 4,
+ });
+ });
+
+ it("is zero when neither today nor yesterday is met", () => {
+ expect(
+ findStreaks(days("2026-09-01", "2026-09-10"), {}, "2025-11-01", "2026-10-05"),
+ ).toEqual({ current: 0, best: 10 });
+ });
+
+ it("finds the best run anywhere in the window", () => {
+ const values = {
+ ...days("2026-03-01", "2026-03-20"),
+ ...days("2026-10-04", "2026-10-05"),
+ };
+ expect(findStreaks(values, {}, "2025-11-01", "2026-10-05")).toEqual({
+ current: 2,
+ best: 20,
+ });
+ });
+
+ it("judges each day against its own month", () => {
+ const stored = { "2026-10": { jobs: 3, hours: 4 } };
+ const values = {
+ "2026-09-29": met,
+ "2026-09-30": met,
+ "2026-10-01": { jobs: 3, hours: 4 },
+ "2026-10-02": { jobs: 3, hours: 4 },
+ };
+ expect(findStreaks(values, stored, "2025-11-01", "2026-10-02")).toEqual({
+ current: 4,
+ best: 4,
+ });
+ // 4 jobs met October's 3 but not September's 5
+ const broken = { ...values, "2026-09-30": { jobs: 4, hours: 4 } };
+ expect(findStreaks(broken, stored, "2025-11-01", "2026-10-02")).toEqual({
+ current: 2,
+ best: 2,
+ });
+ });
+
+ it("ignores values before the window", () => {
+ expect(
+ findStreaks(days("2025-10-25", "2025-11-03"), {}, "2025-11-01", "2026-10-05"),
+ ).toEqual({ current: 0, best: 3 });
+ });
+
+ it("returns zeros with no data", () => {
+ expect(findStreaks({}, {}, "2025-11-01", "2026-10-05")).toEqual({
+ current: 0,
+ best: 0,
+ });
+ });
+ });
});
diff --git a/src/actions/dailyGoals.actions.ts b/src/actions/dailyGoals.actions.ts
index c0e2380..33ef4da 100644
--- a/src/actions/dailyGoals.actions.ts
+++ b/src/actions/dailyGoals.actions.ts
@@ -6,6 +6,7 @@ import { handleError } from "@/lib/utils";
import { requireUser } from "@/actions/shared";
import {
buildGoalValues,
+ findStreaks,
goalMonthRange,
isValidMonth,
monthBounds,
@@ -15,6 +16,7 @@ import {
} from "@/lib/dailyGoals";
import {
GoalTargetsSchema,
+ type GoalStreaks,
type GoalTargetsByMonth,
} from "@/models/dailyGoals.model";
import { defaultUserSettings } from "@/models/userSettings.model";
@@ -53,6 +55,32 @@ async function loadStoredTargets(userId: string): Promise<{
return { settings, targets: parseStoredTargets(settings?.goals?.targets) };
}
+async function computeStreaks(
+ userId: string,
+ targets: GoalTargetsByMonth,
+): Promise<GoalStreaks> {
+ const now = new Date();
+ const today = format(now, "yyyy-MM-dd");
+ const { minMonth } = goalMonthRange(today);
+ const end = new Date(now);
+ end.setHours(23, 59, 59, 999);
+ const values = await loadGoalValues(userId, monthBounds(minMonth).start, end);
+ return findStreaks(values, targets, `${minMonth}-01`, today);
+}
+
+export async function getGoalStreaks(): Promise<
+ { success: true; data: GoalStreaks } | Failure
+> {
+ try {
+ const user = await requireUser();
+ const { targets } = await loadStoredTargets(user.id);
+ return { success: true, data: await computeStreaks(user.id, targets) };
+ } catch (error) {
+ const { message } = handleError(error, "Failed to load goal streaks.");
+ return { success: false, message };
+ }
+}
+
export async function getDailyGoalValues(
month: string,
): Promise<{ success: true; data: GoalMonthData } | Failure> {
@@ -87,7 +115,11 @@ export async function updateGoalTargets(input: {
jobs: number;
hours: number;
}): Promise<
- { success: true; data: { targets: GoalTargetsByMonth } } | Failure
+ | {
+ success: true;
+ data: { targets: GoalTargetsByMonth; streaks: GoalStreaks | null };
+ }
+ | Failure
> {
try {
const user = await requireUser();
@@ -118,7 +150,13 @@ export async function updateGoalTargets(input: {
update: { settings: json },
create: { userId: user.id, settings: json },
});
- return { success: true, data: { targets } };
+ let streaks: GoalStreaks | null = null;
+ try {
+ streaks = await computeStreaks(user.id, targets);
+ } catch {
+ // The targets are saved; the rows show "—" until the next load
+ }
+ return { success: true, data: { targets, streaks } };
} catch (error) {
const { message } = handleError(error, "Failed to save daily goals.");
return { success: false, message };
diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx
index 628c1ea..deff94a 100644
--- a/src/app/dashboard/page.tsx
+++ b/src/app/dashboard/page.tsx
@@ -7,7 +7,10 @@ import {
getRecentActivities,
getRecentJobs,
} from "@/actions/dashboard.actions";
-import { getDailyGoalValues } from "@/actions/dailyGoals.actions";
+import {
+ getDailyGoalValues,
+ getGoalStreaks,
+} from "@/actions/dailyGoals.actions";
import ActivityCalendar from "@/components/dashboard/ActivityCalendar";
import DailyGoalsCalendar from "@/components/dashboard/DailyGoalsCalendar";
import JobsActivityCard from "@/components/dashboard/JobsActivityCard";
@@ -33,6 +36,7 @@ export default async function Dashboard() {
activitiesData,
activityCalendarData,
dailyGoals,
+ goalStreaks,
] = await Promise.all([
getJobsActivitySummary(7),
getJobsActivitySummary(30),
@@ -42,6 +46,7 @@ export default async function Dashboard() {
getActivityDataForPeriod(),
getActivityCalendarData(),
getDailyGoalValues(today.slice(0, 7)),
+ getGoalStreaks(),
]);
const activityCalendarDataKeys = Object.keys(activityCalendarData);
return (
@@ -86,6 +91,7 @@ export default async function Dashboard() {
<DailyGoalsCalendar
today={today}
initialData={dailyGoals.success ? dailyGoals.data : null}
+ initialStreaks={goalStreaks.success ? goalStreaks.data : null}
/>
</div>
<div className="w-full col-span-3">
diff --git a/src/components/dashboard/DailyGoalsCalendar.tsx b/src/components/dashboard/DailyGoalsCalendar.tsx
index 7c53840..7b0acf5 100644
--- a/src/components/dashboard/DailyGoalsCalendar.tsx
+++ b/src/components/dashboard/DailyGoalsCalendar.tsx
@@ -20,6 +20,7 @@ import {
import { toastError } from "@/lib/toast";
import { cn } from "@/lib/utils";
import type {
+ GoalStreaks,
GoalTargets,
GoalTargetsByMonth,
} from "@/models/dailyGoals.model";
@@ -38,11 +39,13 @@ const goalsFor = (targets: GoalTargets): GcGoal[] => [
interface DailyGoalsCalendarProps {
today: string;
initialData: GoalMonthData | null;
+ initialStreaks: GoalStreaks | null;
}
export default function DailyGoalsCalendar({
today,
initialData,
+ initialStreaks,
}: DailyGoalsCalendarProps) {
const { minMonth, maxMonth } = goalMonthRange(today);
const [month, setMonth] = useState(maxMonth);
@@ -54,6 +57,7 @@ export default function DailyGoalsCalendar({
const [storedTargets, setStoredTargets] =
useState<GoalTargetsByMonth | null>(initialData?.targets ?? null);
const targetsFor = (key: string) => resolveTargets(key, storedTargets ?? {});
+ const [streaks, setStreaks] = useState(initialStreaks);
const [loadingMonth, setLoadingMonth] = useState<string | null>(null);
// Only cached months get an entry; the rest show the package's "—"
@@ -65,10 +69,11 @@ export default function DailyGoalsCalendar({
values,
today,
resolveTargets(key, storedTargets ?? {}),
+ streaks,
);
}
return data;
- }, [valuesByMonth, storedTargets, today]);
+ }, [valuesByMonth, storedTargets, streaks, today]);
const handleMonthChange = async (next: string) => {
setMonth(next);
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index b2ceb77..c809175 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -459,6 +459,4 @@ export const DAILY_GOALS = {
HOURS_MAX: 24,
// Months browsable before the current one
MONTHS_BACK: 11,
- // Shown until streaks are computed across months
- PLACEHOLDER_STREAKS: { CURRENT: 3, BEST: 7 },
} as const;
diff --git a/src/lib/dailyGoals.ts b/src/lib/dailyGoals.ts
index 82cfbe8..ecf5454 100644
--- a/src/lib/dailyGoals.ts
+++ b/src/lib/dailyGoals.ts
@@ -3,6 +3,7 @@ import type { GcMonthSummaryProps } from "react-goal-calendar";
import { DAILY_GOALS } from "@/lib/constants";
import {
GoalTargetsSchema,
+ type GoalStreaks,
type GoalTargets,
type GoalTargetsByMonth,
} from "@/models/dailyGoals.model";
@@ -114,6 +115,7 @@ export function buildMonthSummary(
values: GoalValues,
today: string,
targets: GoalTargets,
+ streaks: GoalStreaks | null,
): MonthSummary {
const hit: Record<string, number> = {};
const counted: Record<string, number> = {};
@@ -146,12 +148,12 @@ export function buildMonthSummary(
stats: [
{
label: "Current streak",
- value: formatDays(DAILY_GOALS.PLACEHOLDER_STREAKS.CURRENT),
+ value: streaks ? formatDays(streaks.current) : "—",
tone: "primary",
},
{
- label: "Best streak",
- value: formatDays(DAILY_GOALS.PLACEHOLDER_STREAKS.BEST),
+ label: "Best streak (12 mo)",
+ value: streaks ? formatDays(streaks.best) : "—",
tone: "warning",
},
{ label: "Both goals met", value: formatDays(bothMet), tone: "success" },
@@ -163,3 +165,30 @@ export function buildMonthSummary(
],
};
}
+
+export function findStreaks(
+ values: GoalValues,
+ stored: GoalTargetsByMonth,
+ from: string,
+ today: string,
+): GoalStreaks {
+ const byMonth: Record<string, GoalTargets> = {};
+ let run = 0;
+ let best = 0;
+ const [y, m, d] = from.split("-").map(Number);
+ for (const day = new Date(y, m - 1, d); ; day.setDate(day.getDate() + 1)) {
+ const key = format(day, "yyyy-MM-dd");
+ if (key > today) break;
+ const month = key.slice(0, 7);
+ const targets = (byMonth[month] ??= resolveTargets(month, stored));
+ const v = values[key] ?? {};
+ if (IDS.every((id) => (v[id] ?? 0) >= targets[id])) {
+ run++;
+ best = Math.max(best, run);
+ } else if (key !== today) {
+ // An unfinished today never breaks the run
+ run = 0;
+ }
+ }
+ return { current: run, best };
+}
diff --git a/src/models/dailyGoals.model.ts b/src/models/dailyGoals.model.ts
index d4562cc..f58e6db 100644
--- a/src/models/dailyGoals.model.ts
+++ b/src/models/dailyGoals.model.ts
@@ -17,3 +17,8 @@ export type GoalTargets = z.infer<typeof GoalTargetsSchema>;
// Keyed by "YYYY-MM"; a month with no entry carries the latest earlier one
export type GoalTargetsByMonth = Record<string, GoalTargets>;
+
+export interface GoalStreaks {
+ current: number;
+ best: number;
+}