From e69e0b3941545f5c6f2ced291b1bcf0b69a5baff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 27 Jul 2026 23:27:18 +0200 Subject: [PATCH] fix(admin): count every record class in the upload summary The total shown after a backup upload skipped the nutrient day totals, so a file that carried and restored them reported fewer records than it held. Same defect as the payload gaps this branch closes, on the reporting side. Counts the nutrient days, the health profile and the custom metrics with their readings. --- src/components/admin/backups-section.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/admin/backups-section.tsx b/src/components/admin/backups-section.tsx index 8fc8beb1d..1c8852914 100644 --- a/src/components/admin/backups-section.tsx +++ b/src/components/admin/backups-section.tsx @@ -239,6 +239,13 @@ export function BackupsSection() { familyHistory?: number; workouts?: number; documents?: number; + // Optional for the same reason: a file written before each of these + // rode the wire carries no key, and an absent key must total as + // nothing rather than break the count. + nutrientDays?: number; + healthProfile?: number; + customMetrics?: number; + customMetricEntries?: number; }; }>("/api/admin/backups/upload", { method: "POST", body: fd }); }, @@ -257,7 +264,15 @@ export function BackupsSection() { (data.summary.allergies ?? 0) + (data.summary.familyHistory ?? 0) + (data.summary.workouts ?? 0) + - (data.summary.documents ?? 0); + (data.summary.documents ?? 0) + + // The count the admin is shown has to be the count the file carries. + // The nutrient day totals were added to the payload and never to this + // sum, so an upload that restored them reported fewer records than it + // held — a smaller version of the same defect, on the reporting side. + (data.summary.nutrientDays ?? 0) + + (data.summary.healthProfile ?? 0) + + (data.summary.customMetrics ?? 0) + + (data.summary.customMetricEntries ?? 0); toast.success( t("admin.section.backups.uploadSuccess", { count: String(total) }), );