Added streak percentage

This commit is contained in:
George Powell
2026-02-21 16:17:06 -05:00
parent c3307b3920
commit 6554ef8f41
6 changed files with 143 additions and 17 deletions

View File

@@ -5,3 +5,11 @@ export async function fetchStreak(anonymousId: string, localDate: string): Promi
const data = await res.json();
return typeof data.streak === 'number' ? data.streak : 0;
}
export async function fetchStreakPercentile(streak: number, localDate: string): Promise<number | null> {
const params = new URLSearchParams({ streak: String(streak), localDate });
const res = await fetch(`/api/streak-percentile?${params}`);
if (!res.ok) return null;
const data = await res.json();
return typeof data.percentile === 'number' ? data.percentile : null;
}