mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
refactor(analytics): export ContributingSource so its callers stop spelling the union
The literal "manual" | "withings" | "appleHealth" was spelled in six places across health-score.ts and the analytics route, plus once in the card. The lib helper and the route now read from a single ContributingSource alias; the card keeps its local copy on purpose so the client bundle stays free of analytics imports. Closes W10 simplifier S9 (lib + route scope).
This commit is contained in:
1 parent
4ab0d17808
commit
bbc0afd555
2 files changed
+20
-15
No files matched your search
@@ -10,6 +10,7 @@ import { calculateCompliance } from "@/lib/analytics/compliance";
|
||||
import {
|
||||
computeHealthScore,
|
||||
defaultWeightTargetFromHeight,
|
||||
type ContributingSource,
|
||||
type HealthScoreInput,
|
||||
type HealthScoreResult,
|
||||
} from "@/lib/analytics/health-score";
|
||||
@@ -662,7 +663,7 @@ function isoWeekdayInTz(d: Date, timeZone: string): number {
|
||||
*/
|
||||
function mapMeasurementSourceToLabel(
|
||||
source: MeasurementSource,
|
||||
): "manual" | "withings" | "appleHealth" | null {
|
||||
): ContributingSource | null {
|
||||
switch (source) {
|
||||
case "MANUAL":
|
||||
case "IMPORT":
|
||||
@@ -684,8 +685,8 @@ function mapMeasurementSourceToLabel(
|
||||
*/
|
||||
function uniqueComponentSources(
|
||||
rows: ReadonlyArray<MeasurementSource>,
|
||||
): ReadonlyArray<"manual" | "withings" | "appleHealth"> {
|
||||
const seen = new Set<"manual" | "withings" | "appleHealth">();
|
||||
): ReadonlyArray<ContributingSource> {
|
||||
const seen = new Set<ContributingSource>();
|
||||
for (const src of rows) {
|
||||
const label = mapMeasurementSourceToLabel(src);
|
||||
if (label) seen.add(label);
|
||||
|
||||
Reference in new issue
Block a user