mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
chore(knip): mute shadcn surface + drop two duplicate helpers
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`.
This commit is contained in:
1 parent
a2390a1ee3
commit
c032dfb617
3 files changed
+8
-37
No files matched your search
@@ -69,5 +69,9 @@
|
||||
"docker-compose",
|
||||
"pg_isready",
|
||||
"tsx"
|
||||
]
|
||||
],
|
||||
"ignoreExportsUsedInFile": true,
|
||||
"ignoreIssues": {
|
||||
"src/components/ui/**": ["exports", "types"]
|
||||
}
|
||||
}
|
||||
@@ -185,13 +185,3 @@ export async function destroyAllSessions(userId: string): Promise<void> {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Require an authenticated admin user.
|
||||
* Returns user if admin, null otherwise.
|
||||
*/
|
||||
export async function requireAdmin(): Promise<User | null> {
|
||||
const sessionData = await getSession();
|
||||
if (!sessionData) return null;
|
||||
if (sessionData.user.role !== "ADMIN") return null;
|
||||
return sessionData.user;
|
||||
}
|
||||
@@ -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<DailyMeanRow[]> {
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user