From 76698684799792ee0d0e4f72a6f16e8dd1e9063d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 7 Aug 2026 18:32:38 +0200 Subject: [PATCH] refactor(measurements): drop the entry-unit helpers nothing calls `hasEntryUnitConversion` and `canonicalValueToEntry` shipped beside the hours-to-minutes conversion for an editing surface that does not exist and has no ticket. Neither has a caller, so both were only two more things to keep true, and the dead-code gate is right to say so. The module comment claimed the inverse was there so a future surface could not land on a different answer. It says what is actually true now: one direction, one place. The git history keeps the rest if that surface ever arrives. --- src/lib/measurements/entry-units.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib/measurements/entry-units.ts b/src/lib/measurements/entry-units.ts index 147886507..73e2a1e45 100644 --- a/src/lib/measurements/entry-units.ts +++ b/src/lib/measurements/entry-units.ts @@ -16,8 +16,14 @@ * that short. * * The storage unit stays minutes. The conversion belongs at the entry - * boundary, in one place, with the inverse beside it so a future editing - * surface cannot land on a different answer. + * boundary, in one place, so a second surface that starts taking sleep by hand + * has one answer to reach for rather than its own. + * + * Only the direction that exists is here. An inverse and a "does this type + * convert" predicate shipped alongside it at first, written for an editing + * surface that does not exist and has no ticket; they were nothing but two + * more things to keep true. The git history holds them if that surface ever + * arrives. */ export const MINUTES_PER_HOUR = 60; @@ -30,11 +36,6 @@ const ENTRY_TO_CANONICAL_FACTOR: Readonly> = { SLEEP_DURATION: MINUTES_PER_HOUR, }; -/** Whether the type's entry unit differs from the unit its column stores. */ -export function hasEntryUnitConversion(type: string): boolean { - return type in ENTRY_TO_CANONICAL_FACTOR; -} - /** * Convert a value as typed in the entry form to the unit the column stores. * @@ -49,13 +50,6 @@ export function entryValueToCanonical(type: string, entered: number): number { return Math.round(entered * factor); } -/** The inverse: a stored value expressed in the unit the entry form asks for. */ -export function canonicalValueToEntry(type: string, canonical: number): number { - const factor = ENTRY_TO_CANONICAL_FACTOR[type]; - if (factor === undefined || !Number.isFinite(canonical)) return canonical; - return canonical / factor; -} - /** * Read a number out of an entry field, accepting the decimal comma. *