style: apply prettier across the tree

One-shot prettier pass so the new format:check gate starts from a clean
baseline. Formatting only — no behaviour change. Generator-owned and
vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
Marc-André Bombeck committed 2026-06-19 22:20:31 +02:00
1 parent b3fea2ef59
commit 1f4ba5939d
1000 files changed
+12130 -8385

No files matched your search

@@ -41,10 +41,7 @@ function row(
describe("collapseRollupRowsBySource", () => {
it("picks WHOOP over Apple for resting heart rate (ladder head wins)", () => {
const out = collapseRollupRowsBySource(
[
row(DAY1, "APPLE_HEALTH", 54),
row(DAY1, "WHOOP", 51),
],
[row(DAY1, "APPLE_HEALTH", 54), row(DAY1, "WHOOP", 51)],
"RESTING_HEART_RATE",
null,
);
@@ -55,10 +52,7 @@ describe("collapseRollupRowsBySource", () => {
it("picks Withings over Apple for SpO₂", () => {
const out = collapseRollupRowsBySource(
[
row(DAY1, "APPLE_HEALTH", 96),
row(DAY1, "WITHINGS", 98),
],
[row(DAY1, "APPLE_HEALTH", 96), row(DAY1, "WITHINGS", 98)],
"OXYGEN_SATURATION",
null,
);
@@ -69,10 +63,7 @@ describe("collapseRollupRowsBySource", () => {
it("picks native WHOOP over the COMPUTED proxy for RECOVERY_SCORE", () => {
const out = collapseRollupRowsBySource(
[
row(DAY1, "COMPUTED", 62),
row(DAY1, "WHOOP", 70),
],
[row(DAY1, "COMPUTED", 62), row(DAY1, "WHOOP", 70)],
"RECOVERY_SCORE",
null,
);
@@ -125,10 +116,7 @@ describe("collapseRollupRowsBySource", () => {
restingHeartRate: ["APPLE_HEALTH", "WHOOP", "WITHINGS"],
};
const out = collapseRollupRowsBySource(
[
row(DAY1, "WHOOP", 51),
row(DAY1, "APPLE_HEALTH", 54),
],
[row(DAY1, "WHOOP", 51), row(DAY1, "APPLE_HEALTH", 54)],
"RESTING_HEART_RATE",
custom,
);
@@ -141,10 +129,7 @@ describe("collapseRollupRowsBySource", () => {
// row deterministically by source name, matching the live-SQL paths'
// `ORDER BY … source` tiebreak (live/rollup parity).
const out = collapseRollupRowsBySource(
[
row(DAY1, "MANUAL", 58, 5),
row(DAY1, "IMPORT", 60, 2),
],
[row(DAY1, "MANUAL", 58, 5), row(DAY1, "IMPORT", 60, 2)],
"RESTING_HEART_RATE",
null,
);
@@ -497,9 +497,7 @@ describe("enqueueRollupRecompute", () => {
expect(payload.from).toBe(from.toISOString());
// The singleton key collapses repeat enqueues for the same bucket
// so a multi-write minute doesn't fan out one worker run per row.
expect(opts.singletonKey).toBe(
`user-9|PULSE|WEEK|${from.toISOString()}`,
);
expect(opts.singletonKey).toBe(`user-9|PULSE|WEEK|${from.toISOString()}`);
});
});
@@ -735,7 +733,7 @@ describe("enqueueBootTimeRollupBackfill", () => {
const sqlParts = queryRaw.mock.calls[0][0] as TemplateStringsArray;
const sqlText = Array.isArray(sqlParts) ? sqlParts.join("?") : "";
// Inner DISTINCT widens to `(user_id, type, bucket_start)`.
expect(sqlText).toContain('date_trunc(\'day\', m."measured_at")');
expect(sqlText).toContain("date_trunc('day', m.\"measured_at\")");
// LEFT JOIN now compares bucket_start on both sides.
expect(sqlText).toContain('r."bucket_start" = mt."bucket_start"');
});
@@ -159,7 +159,9 @@ describe("recomputeMedicationComplianceForDay", () => {
"?",
);
expect(insertSql).toMatch(/GROUP BY\s+"scheduled_for"/);
expect(insertSql).toMatch(/BOOL_OR\("taken_at" IS NOT NULL AND NOT "skipped"\)/);
expect(insertSql).toMatch(
/BOOL_OR\("taken_at" IS NOT NULL AND NOT "skipped"\)/,
);
expect(insertSql).toMatch(/BOOL_OR\("skipped"\)/);
// Slot-level taken beats skipped: a slot is `skipped` only when no row
// in it is taken.
@@ -37,7 +37,10 @@ vi.mock("@/lib/db", () => ({
},
}));
import { buildTieredSeries, buildTieredSeriesForTypes } from "../tiered-context";
import {
buildTieredSeries,
buildTieredSeriesForTypes,
} from "../tiered-context";
const NOW = new Date("2026-06-19T00:00:00.000Z").getTime();
+2 -8
View File
@@ -600,9 +600,7 @@ function bucketSpan(
// Postgres ISO week: Monday is day 1. JS getUTCDay(): Sunday=0..Saturday=6.
const dayOfWeek = day.getUTCDay(); // 0=Sun
const mondayOffset = (dayOfWeek + 6) % 7; // 0 for Mon … 6 for Sun
const from = new Date(
day.getTime() - mondayOffset * 24 * 60 * 60 * 1000,
);
const from = new Date(day.getTime() - mondayOffset * 24 * 60 * 60 * 1000);
return { from, to: new Date(from.getTime() + 7 * 24 * 60 * 60 * 1000) };
}
case "MONTH": {
@@ -610,11 +608,7 @@ function bucketSpan(
Date.UTC(measuredAt.getUTCFullYear(), measuredAt.getUTCMonth(), 1),
);
const to = new Date(
Date.UTC(
measuredAt.getUTCFullYear(),
measuredAt.getUTCMonth() + 1,
1,
),
Date.UTC(measuredAt.getUTCFullYear(), measuredAt.getUTCMonth() + 1, 1),
);
return { from, to };
}
@@ -50,11 +50,7 @@
import { prisma } from "@/lib/db";
import { getGlobalBoss } from "@/lib/jobs/boss-instance";
import { annotate } from "@/lib/logging/context";
import {
DEFAULT_TIMEZONE,
isValidTimezone,
userDayKey,
} from "@/lib/tz/format";
import { DEFAULT_TIMEZONE, isValidTimezone, userDayKey } from "@/lib/tz/format";
import { wallClockInTz } from "@/lib/tz/wall-clock";
/**
@@ -296,10 +292,7 @@ export async function recomputeMedicationComplianceForEvent(input: {
medication_compliance_rollup_error: message,
},
});
console.error(
"[medication-compliance-rollups] recompute failed:",
message,
);
console.error("[medication-compliance-rollups] recompute failed:", message);
}
}
+22 -16
View File
@@ -154,7 +154,12 @@ export async function recomputeUserMoodRollups(
});
if (rows.length === 0) continue;
rowsUpserted += await persistMoodRollupRows(prisma, userId, granularity, rows);
rowsUpserted += await persistMoodRollupRows(
prisma,
userId,
granularity,
rows,
);
}
return { rowsUpserted, durationMs: Date.now() - startedAt };
@@ -242,18 +247,21 @@ export async function recomputeMoodBucketsForEntry(
void Promise.all(
ASYNC_GRANULARITIES.map((granularity) => {
const { from, to } = bucketSpan(moodLoggedAt, granularity);
return enqueueMoodRollupRecompute({ userId, granularity, from, to }).catch(
(err: unknown) => {
const message = err instanceof Error ? err.message : String(err);
annotate({
meta: {
mood_rollup_enqueue_failed: true,
mood_rollup_enqueue_error: message,
},
});
console.error("[mood-rollups] async enqueue failed:", message);
},
);
return enqueueMoodRollupRecompute({
userId,
granularity,
from,
to,
}).catch((err: unknown) => {
const message = err instanceof Error ? err.message : String(err);
annotate({
meta: {
mood_rollup_enqueue_failed: true,
mood_rollup_enqueue_error: message,
},
});
console.error("[mood-rollups] async enqueue failed:", message);
});
}),
);
}
@@ -631,9 +639,7 @@ function bucketSpan(
// Postgres ISO week: Monday is day 1. JS getUTCDay(): Sunday=0.
const dayOfWeek = day.getUTCDay();
const mondayOffset = (dayOfWeek + 6) % 7;
const from = new Date(
day.getTime() - mondayOffset * 24 * 60 * 60 * 1000,
);
const from = new Date(day.getTime() - mondayOffset * 24 * 60 * 60 * 1000);
return { from, to: new Date(from.getTime() + 7 * 24 * 60 * 60 * 1000) };
}
case "MONTH": {
+32 -4
View File
@@ -299,12 +299,40 @@ export async function buildTieredSeries(
: readRecentDaily(userId, type, now),
coarseOnly
? emptyBand
: readBand(userId, type, "DAY", TIERED_BANDS.dayUntil, TIERED_BANDS.rawDays, now),
: readBand(
userId,
type,
"DAY",
TIERED_BANDS.dayUntil,
TIERED_BANDS.rawDays,
now,
),
coarseOnly
? emptyBand
: readBand(userId, type, "WEEK", TIERED_BANDS.weekUntil, TIERED_BANDS.dayUntil, now),
readBand(userId, type, "MONTH", TIERED_BANDS.monthUntil, TIERED_BANDS.weekUntil, now),
readBand(userId, type, "YEAR", TIERED_BANDS.yearUntil, TIERED_BANDS.monthUntil, now),
: readBand(
userId,
type,
"WEEK",
TIERED_BANDS.weekUntil,
TIERED_BANDS.dayUntil,
now,
),
readBand(
userId,
type,
"MONTH",
TIERED_BANDS.monthUntil,
TIERED_BANDS.weekUntil,
now,
),
readBand(
userId,
type,
"YEAR",
TIERED_BANDS.yearUntil,
TIERED_BANDS.monthUntil,
now,
),
]);
// Window stats span every coarse bucket so the anomaly threshold reflects