mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(gki): build the index from the glucose shown beside it
A reading entered in mmol/L is stored as whole mg/dL, and the index divided the unrounded conversion, so a 5.2 / 0.3 pair printed beside a 17.4 rather than 17.3. Round the glucose to the decimal it is shown with first and divide that. The tiles also printed a two-decimal ketone reading to one decimal; show it as recorded.
This commit is contained in:
1 parent
c8b32ccaea
commit
5ebfac1259
5 files changed
+72
-22
No files matched your search
@@ -4,7 +4,10 @@ import Link from "next/link";
|
||||
|
||||
import type { DayResponse } from "@/lib/day/contract";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import { GKI_COMPONENT_UNIT } from "@/lib/measurements/glucose-ketone-index";
|
||||
import {
|
||||
GKI_COMPONENT_UNIT,
|
||||
ketoneFractionDigits,
|
||||
} from "@/lib/measurements/glucose-ketone-index";
|
||||
|
||||
type DayGki = NonNullable<DayResponse["glucoseKetoneIndex"]>[number];
|
||||
|
||||
@@ -38,7 +41,10 @@ export function DayGkiTile({ points }: { points: readonly DayGki[] }) {
|
||||
? tCount("day.gkiCount", points.length)
|
||||
: t("day.gkiPair", {
|
||||
glucose: fmt.number(latest.glucoseMmol, 1),
|
||||
ketones: fmt.number(latest.ketonesMmol, 1),
|
||||
ketones: fmt.number(
|
||||
latest.ketonesMmol,
|
||||
ketoneFractionDigits(latest.ketonesMmol),
|
||||
),
|
||||
unit: GKI_COMPONENT_UNIT,
|
||||
})}
|
||||
</span>
|
||||
|
||||
@@ -17,7 +17,10 @@ import {
|
||||
} from "@/components/ui/card";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import { GKI_COMPONENT_UNIT } from "@/lib/measurements/glucose-ketone-index";
|
||||
import {
|
||||
GKI_COMPONENT_UNIT,
|
||||
ketoneFractionDigits,
|
||||
} from "@/lib/measurements/glucose-ketone-index";
|
||||
import { useGlucoseKetoneIndexSeries } from "@/lib/queries/use-glucose-ketone-index";
|
||||
import { importWithRetry } from "@/lib/retry-import";
|
||||
|
||||
@@ -78,7 +81,10 @@ export function GkiCard() {
|
||||
{t("insights.bloodKetones.gki.latest", {
|
||||
value: fmt.number(latest.value, 1),
|
||||
glucose: fmt.number(latest.gki.glucoseMmol, 1),
|
||||
ketones: fmt.number(latest.gki.ketonesMmol, 1),
|
||||
ketones: fmt.number(
|
||||
latest.gki.ketonesMmol,
|
||||
ketoneFractionDigits(latest.gki.ketonesMmol),
|
||||
),
|
||||
unit: GKI_COMPONENT_UNIT,
|
||||
date: fmt.dateTime(latest.at),
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user