From daaa44fd82467a09689935e4f5e6bfc41020206d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 23 Oct 2026 11:21:29 +0200 Subject: [PATCH] refactor(insights): read the mood bands from a leaf module so mood-patterns no longer imports its hub --- src/lib/insights/mood-aggregates.ts | 18 ++++++++---------- src/lib/insights/mood-bands.ts | 12 ++++++++++++ src/lib/insights/mood-patterns.ts | 9 ++++----- 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 src/lib/insights/mood-bands.ts diff --git a/src/lib/insights/mood-aggregates.ts b/src/lib/insights/mood-aggregates.ts index 772621ed5..5112f498c 100644 --- a/src/lib/insights/mood-aggregates.ts +++ b/src/lib/insights/mood-aggregates.ts @@ -283,16 +283,14 @@ export const MOOD_CROSS_METRIC_ROW_CAP = 50_000; // --- Target bands (mirror mood-chart VALUE_BANDS + mood-status) --- -/** - * The mood-status generator grades "in target" as score >= 3.5. The - * mood-chart paints three reference bands (1–2 red, 2–3 orange, 3–5 - * green). We keep both anchored here so the heatmap colour map and the - * in-target headline never drift from the line chart. - */ -export const MOOD_GREEN_MIN = 3.5; -export const MOOD_GREEN_MAX = 5; -export const MOOD_ORANGE_MIN = 2; -export const MOOD_ORANGE_MAX = 3.5; +// Defined in a leaf module so the per-domain modules this hub re-exports can +// read them without importing the hub back. +export { + MOOD_GREEN_MAX, + MOOD_GREEN_MIN, + MOOD_ORANGE_MAX, + MOOD_ORANGE_MIN, +} from "@/lib/insights/mood-bands"; // --- Pair two daily-bucket series on dayOffset (lifted from mood-status) --- diff --git a/src/lib/insights/mood-bands.ts b/src/lib/insights/mood-bands.ts new file mode 100644 index 000000000..3bd1a43db --- /dev/null +++ b/src/lib/insights/mood-bands.ts @@ -0,0 +1,12 @@ +/** + * The mood scale's target bands (mirror mood-chart VALUE_BANDS + mood-status). + * + * The mood-status generator grades "in target" as score >= 3.5. The + * mood-chart paints three reference bands (1–2 red, 2–3 orange, 3–5 + * green). We keep both anchored here so the heatmap colour map and the + * in-target headline never drift from the line chart. + */ +export const MOOD_GREEN_MIN = 3.5; +export const MOOD_GREEN_MAX = 5; +export const MOOD_ORANGE_MIN = 2; +export const MOOD_ORANGE_MAX = 3.5; diff --git a/src/lib/insights/mood-patterns.ts b/src/lib/insights/mood-patterns.ts index 289748095..855485325 100644 --- a/src/lib/insights/mood-patterns.ts +++ b/src/lib/insights/mood-patterns.ts @@ -11,11 +11,10 @@ */ import { dayOffsetToDayKey } from "@/lib/insights/bucket-series"; -import { - MOOD_GREEN_MAX, - MOOD_GREEN_MIN, - type DailyPoint, - type MoodAggregateEntry, +import { MOOD_GREEN_MAX, MOOD_GREEN_MIN } from "@/lib/insights/mood-bands"; +import type { + DailyPoint, + MoodAggregateEntry, } from "@/lib/insights/mood-aggregates"; import { round } from "@/lib/insights/status-shared"; import { DEFAULT_TIMEZONE } from "@/lib/tz/format";