mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-04-06 01:43:32 -04:00
no longer initializes embeddings model on startup
This commit is contained in:
@@ -27,9 +27,9 @@ export const load: PageServerLoad = async ({ url, locals }) => {
|
||||
};
|
||||
}
|
||||
|
||||
// Get user's current date from timezone query param
|
||||
const timezone = url.searchParams.get('tz') || 'UTC';
|
||||
const userToday = new Date().toLocaleDateString('en-CA', { timeZone: timezone });
|
||||
// Note: userToday is used only for the initial server-side streak estimate.
|
||||
// The client overrides this with a precise local-date calculation via /api/streak.
|
||||
const userToday = new Date().toISOString().slice(0, 10); // UTC date as safe fallback
|
||||
|
||||
try {
|
||||
// Get all completions for this user
|
||||
@@ -85,7 +85,7 @@ export const load: PageServerLoad = async ({ url, locals }) => {
|
||||
'C': completions.filter((c: DailyCompletion) => c.guessCount > 15).length
|
||||
};
|
||||
|
||||
// Calculate streaks
|
||||
// Calculate streaks — dates are stored as the user's local date
|
||||
const sortedDates = completions
|
||||
.map((c: DailyCompletion) => c.date)
|
||||
.sort();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
formatDate,
|
||||
type UserStats,
|
||||
} from "$lib/utils/stats";
|
||||
import { fetchStreak } from "$lib/utils/streak";
|
||||
|
||||
interface PageData {
|
||||
stats: UserStats | null;
|
||||
@@ -22,6 +23,7 @@
|
||||
let anonymousId = $state("");
|
||||
|
||||
let loading = $state(true);
|
||||
let currentStreak = $state(0);
|
||||
|
||||
function getOrCreateAnonymousId(): string {
|
||||
if (!browser) return "";
|
||||
@@ -36,6 +38,12 @@
|
||||
|
||||
onMount(async () => {
|
||||
anonymousId = getOrCreateAnonymousId();
|
||||
if (data.user?.id) {
|
||||
const localDate = new Date().toLocaleDateString("en-CA");
|
||||
currentStreak = await fetchStreak(data.user.id, localDate);
|
||||
} else {
|
||||
currentStreak = data.stats?.currentStreak ?? 0;
|
||||
}
|
||||
loading = false;
|
||||
});
|
||||
|
||||
@@ -151,7 +159,7 @@
|
||||
<div
|
||||
class="text-2xl md:text-3xl font-bold text-orange-400 mb-1"
|
||||
>
|
||||
{stats.currentStreak}
|
||||
{currentStreak}
|
||||
</div>
|
||||
<div
|
||||
class="text-xs md:text-sm text-gray-300 font-medium"
|
||||
|
||||
Reference in New Issue
Block a user