diff --git a/knip.json b/knip.json index f536ea151..b4b0b610c 100644 --- a/knip.json +++ b/knip.json @@ -69,5 +69,9 @@ "docker-compose", "pg_isready", "tsx" - ] + ], + "ignoreExportsUsedInFile": true, + "ignoreIssues": { + "src/components/ui/**": ["exports", "types"] + } } diff --git a/src/lib/auth/session.ts b/src/lib/auth/session.ts index b00870e64..949c8ca89 100644 --- a/src/lib/auth/session.ts +++ b/src/lib/auth/session.ts @@ -185,13 +185,3 @@ export async function destroyAllSessions(userId: string): Promise { ]); } -/** - * Require an authenticated admin user. - * Returns user if admin, null otherwise. - */ -export async function requireAdmin(): Promise { - const sessionData = await getSession(); - if (!sessionData) return null; - if (sessionData.user.role !== "ADMIN") return null; - return sessionData.user; -} diff --git a/src/lib/rollups/measurement-read.ts b/src/lib/rollups/measurement-read.ts index b8f0be1a1..557c20c74 100644 --- a/src/lib/rollups/measurement-read.ts +++ b/src/lib/rollups/measurement-read.ts @@ -2,10 +2,9 @@ * v1.5.0 — read-side helpers that aggregate the persistent rollup * table into the same `DataSummary` shape the live aggregator * returns. The reader-side surfaces (`summaries-slice`, - * `comprehensive-aggregator`, the analytics route) call - * `readDataSummariesFromRollups` before falling through to live SQL; - * on rollup miss / stale they call `recomputeUserRollups` once to - * persist the buckets, then re-read. + * `comprehensive-aggregator`, the analytics route) re-aggregate the + * trailing DAY buckets directly via `readRollupBuckets` and feed the + * resulting rows into `aggregateBuckets` below. * * The 90-day window is reconstructed from DAY buckets by: * - sum(count_i) → window count @@ -20,8 +19,6 @@ * rollup-read path delegates to live SQL so the byte-shape parity with * the v1.4.34.1 / 4.5 aggregator survives. */ -import type { MeasurementType } from "@/generated/prisma/client"; -import { readRollupBuckets } from "@/lib/rollups/measurement-rollups"; export interface DailyMeanRow { day: Date; @@ -31,26 +28,6 @@ export interface DailyMeanRow { maxValue: number; } -/** - * Read the trailing DAY buckets for `(userId, type)` over `[from, to)` - * and return them as a normalised list. - */ -export async function readDailyMeans( - userId: string, - type: MeasurementType, - from: Date, - to: Date, -): Promise { - const rows = await readRollupBuckets(userId, type, "DAY", from, to); - return rows.map((r) => ({ - day: r.bucketStart, - count: r.count, - mean: r.mean, - minValue: r.minValue, - maxValue: r.maxValue, - })); -} - /** * Combine DAY buckets into the linearly-composable window stats — * `count`, `min`, `max`, `mean`. SD / slope / R² are intentionally