mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(backup): restore the nutrient day totals the export has always carried
The export has written nutrient day totals since v1.29. The canonical schema never declared the field, so `.passthrough()` carried it through parsing and no reader ever looked at it: every water and vitamin total in the file was discarded on restore, and the restore reported success. Declared in the contract, cleared and re-created beside its siblings, and counted in both places that count — what the file holds and what the restore replaced. A count that stops at the domains someone remembered is how this stayed quiet.
This commit is contained in:
1 parent
b2e19ce0b6
commit
d9afb23067
2 files changed
+45
No files matched your search
@@ -58,6 +58,7 @@ interface RestoreResponse {
|
||||
cycleProfile: number;
|
||||
labResults: number;
|
||||
biomarkers: number;
|
||||
nutrientDays: number;
|
||||
illnessEpisodes: number;
|
||||
allergies: number;
|
||||
familyHistory: number;
|
||||
@@ -328,6 +329,12 @@ const handler = apiHandler(
|
||||
const biomarkers = await tx.biomarker.deleteMany({
|
||||
where: { userId: ownerId },
|
||||
});
|
||||
// The export has written nutrient day totals since v1.29 and nothing
|
||||
// here ever read them back: water and vitamin history was carried in
|
||||
// the file, discarded on restore, and the restore reported success.
|
||||
const nutrientDays = await tx.nutrientIntakeDay.deleteMany({
|
||||
where: { userId: ownerId },
|
||||
});
|
||||
|
||||
if (payload.appSettings) {
|
||||
const settings = payload.appSettings;
|
||||
@@ -968,6 +975,19 @@ const handler = apiHandler(
|
||||
});
|
||||
}
|
||||
|
||||
if (payload.nutrientDays.length > 0) {
|
||||
await tx.nutrientIntakeDay.createMany({
|
||||
data: payload.nutrientDays.map((n) => ({
|
||||
userId: ownerId,
|
||||
day: n.day,
|
||||
nutrient: n.nutrient,
|
||||
amount: n.amount,
|
||||
unit: n.unit,
|
||||
source: n.source,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
if (payload.documents.length > 0) {
|
||||
await tx.inboundDocument.createMany({
|
||||
data: payload.documents.map((document) => ({
|
||||
@@ -1018,6 +1038,7 @@ const handler = apiHandler(
|
||||
cycleProfile: cycleCleared.cycleProfile,
|
||||
labResults: labResults.count,
|
||||
biomarkers: biomarkers.count,
|
||||
nutrientDays: nutrientDays.count,
|
||||
illnessEpisodes: illnessEpisodes.count,
|
||||
allergies: allergies.count,
|
||||
familyHistory: familyHistory.count,
|
||||
@@ -1140,6 +1161,7 @@ const handler = apiHandler(
|
||||
cycleDayLogs: summary.cycleDayLogs,
|
||||
labResults: summary.labResults,
|
||||
biomarkers: summary.biomarkers,
|
||||
nutrientDays: summary.nutrientDays,
|
||||
illnessEpisodes: summary.illnessEpisodes,
|
||||
illnessDayLogs: summary.illnessDayLogs,
|
||||
allergies: summary.allergies,
|
||||
|
||||
Reference in new issue
Block a user