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.
This commit is contained in:
Marc-André Bombeck committed 2026-08-07 18:32:38 +02:00
1 parent 384992bb15
commit 7669868479
1 file changed
+8 -14
+8 -14
View File
@@ -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<Record<string, number>> = {
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.
*