Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

unread.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

unread.tsBlame21 lines · 1 contributor
3ef4c9dClaude1/**
2 * Helper to fetch the unread notification count for a user.
3 * Extracted so any handler can pass it to <Layout> without importing the route file.
4 * Errors are swallowed — the nav must never break because of a counter.
5 */
6
7import { and, eq, isNull, sql } from "drizzle-orm";
8import { db } from "../db";
9import { notifications } from "../db/schema";
10
11export async function getUnreadCount(userId: string): Promise<number> {
12 try {
13 const [row] = await db
14 .select({ c: sql<number>`count(*)::int` })
15 .from(notifications)
16 .where(and(eq(notifications.userId, userId), isNull(notifications.readAt)));
17 return row?.c ?? 0;
18 } catch {
19 return 0;
20 }
21}