chore(knip): drop seven dead exports flagged by W-SIMPLIFIER

`tokenKind`, `withBackgroundEventSafe`, and `isRollupFresh` had no
callers anywhere in the tree, so the symbol + JSDoc + index re-export
are removed. `PROGRESS_TICK_RECORDS`, `MAINTAINED_LOCALES`, and
`SUB_PAGE_METRIC` lose the `export` keyword — every reader lives in the
same module, so the constants stay local. `isRollupFresh` was deferred
in v1.4.41 pending the persistent-rollup reader landing on develop; the
read-path now carries its own per-tier freshness probe and never
imported the helper.

No behaviour change. Knip drops from 35 unused exports to 29.
This commit is contained in:
Marc-André Bombeck committed 2026-05-21 19:06:22 +02:00
1 parent dce14fb40c
commit a2390a1ee3
7 files changed
+7 -65

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ export const localeLabels: Record<Locale, string> = {
* know to expect rough edges and where to contribute fixes. Promoting
* a locale here turns the banner off.
*/
export const MAINTAINED_LOCALES: ReadonlySet<Locale> = new Set(["de", "en"]);
const MAINTAINED_LOCALES: ReadonlySet<Locale> = new Set(["de", "en"]);
export function isMaintainedLocale(locale: Locale): boolean {
return MAINTAINED_LOCALES.has(locale);
-7
View File
@@ -205,10 +205,3 @@ export function tokenToMetric(token: ChartToken): string {
return token.slice("metric:".length);
}
/** Token kinds the renderer needs to distinguish. MeasurementType tokens
* feed `<HealthChart>`; `metric:MOOD` mounts the dedicated, self-fetching
* `<MoodChart>` instead. */
export function tokenKind(token: ChartToken): "measurement" | "mood" {
if (token === "metric:MOOD") return "mood";
return "measurement";
}
+1 -1
View File
@@ -40,7 +40,7 @@
// `gewicht`, `bmi`, `schlaf`, `stimmung`, `medikamente`, `workouts`)
// stay flat — they predate v1.4.32 and the maintainer's audit kept
// them as direct entries.
export const SUB_PAGE_METRIC = {
const SUB_PAGE_METRIC = {
// ── vitals ──
blutdruck: ["BLOOD_PRESSURE_SYS", "BLOOD_PRESSURE_DIA", "PULSE"],
puls: ["PULSE"],
-14
View File
@@ -33,17 +33,3 @@ export async function withBackgroundEvent<T>(
});
}
/**
* Fire-and-forget Variante: schluckt Fehler und loggt sie nur.
* Fuer Webhook-Sends, Achievement-Checks, etc.
*/
export async function withBackgroundEventSafe(
taskName: string,
fn: (evt: WideEventBuilder) => Promise<void>,
): Promise<void> {
try {
await withBackgroundEvent(taskName, fn);
} catch {
// Fehler wurde bereits ins Event geschrieben und emittiert
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ export { WideEventBuilder } from "./event-builder";
export { eventStorage, getEvent, annotate } from "./context";
export { shouldEmit } from "./sampler";
export { emitEvent, emitIfSampled } from "./transports";
export { withBackgroundEvent, withBackgroundEventSafe } from "./background";
export { withBackgroundEvent } from "./background";
export {
appendLogEvent,
readLogBuffer,
@@ -148,7 +148,7 @@ interface MutableTypeStat {
}
/** Tick frequency for the live `ImportJob.progress` write. */
export const PROGRESS_TICK_RECORDS = 1_000;
const PROGRESS_TICK_RECORDS = 1_000;
const SPOT_FLUSH_BATCH = 500;
const WORKOUT_FLUSH_BATCH = 100;
+3 -40
View File
@@ -23,10 +23,9 @@
*
* Reads:
* - `readRollupBuckets` returns the persisted rows. The reader
* side (`analytics`, `comprehensive`, `summaries-slice`) calls
* `isRollupFresh` first to decide whether to fall through to the
* live aggregator + persist-on-miss. Cheap heuristic — one
* indexed query for the newest measurement's `measuredAt`.
* side (`analytics`, `comprehensive`, `summaries-slice`) decides
* whether to fall through to the live aggregator + persist-on-miss
* via its own per-tier freshness probe.
*/
import { prisma } from "@/lib/db";
import { getGlobalBoss } from "@/lib/jobs/boss-instance";
@@ -303,42 +302,6 @@ export async function readRollupBuckets(
}));
}
/**
* Cheap freshness heuristic — one indexed query against
* `measurements` for the newest row per (user, type). Returns true
* when the persisted rollup covers every measurement currently in
* the DB, false when there's a newer measurement than the freshest
* rollup row (the rollup needs a recompute).
*
* `null` newest measurement means the user has no rows of this type,
* in which case the rollups are trivially fresh (empty == empty).
*/
export async function isRollupFresh(
userId: string,
type: MeasurementType,
granularity: RollupGranularity,
newestComputedAt: Date | null,
): Promise<boolean> {
const newest = await prisma.measurement.findFirst({
where: { userId, type, deletedAt: null },
orderBy: { measuredAt: "desc" },
select: { measuredAt: true, updatedAt: true },
});
if (!newest) {
// No measurements at all — empty rollup set is fresh by definition.
return true;
}
if (!newestComputedAt) {
// We have measurements but no rollup rows — definitely stale.
return false;
}
// Stale when the latest row was written / updated after the most
// recent rollup `computed_at` for this `(user, type, granularity)`.
const watermark =
newest.updatedAt > newest.measuredAt ? newest.updatedAt : newest.measuredAt;
return watermark <= newestComputedAt;
}
// ─── internals ────────────────────────────────────────────
/**