From c032dfb61711a85a060f1c5d85d2fbe60ebeb7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 21 May 2026 18:52:55 +0200 Subject: [PATCH] chore(knip): mute shadcn surface + drop two duplicate helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every shadcn UI re-export the simplifier residual flagged (`AlertDialogMedia/Overlay/Portal`, `AvatarBadge/Group/GroupCount`, `badgeVariants`, `buttonVariants`, the `Card*` / `Dialog*` / `DropdownMenu*` / `Select*` / `Sheet*` / `Table*` / `tabsListVariants` tier) is part of the upstream `new-york-v4` registry — confirmed against `https://ui.shadcn.com/r/styles/new-york-v4/*.json`. Keeping them in tree preserves library-shape parity so the next shadcn refresh applies cleanly. Mute the whole `src/components/ui/**` surface for the `exports` + `types` issue tiers via `ignoreIssues`. `ignoreExportsUsedInFile: true` covers the schema-source-of-truth pattern across `src/lib/ai/**` + `src/lib/validations/**`: the schemas are exported for the inferred `z.infer<>` type but only referenced internally for composition. Knip's default behaviour flagged them as unused exports; the option teaches it that same-file references count. Two genuine dead helpers go: `requireAdmin` in `src/lib/auth/session.ts` shadowed the real implementation in `src/lib/api-handler.ts` and had no callers, and `readDailyMeans` in `src/lib/rollups/measurement-read.ts` was an unused convenience wrapper around `readRollupBuckets`. --- knip.json | 6 +++++- src/lib/auth/session.ts | 10 ---------- src/lib/rollups/measurement-read.ts | 29 +++-------------------------- 3 files changed, 8 insertions(+), 37 deletions(-) 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