diff --git a/package.json b/package.json index 6b16d83..d2ccab6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homepage", - "version": "1.23.6", + "version": "1.23.7", "private": true, "type": "module", "scripts": { diff --git a/src/routes/fitness/[nutrition=fitnessNutrition]/[[date=fitnessDate]]/+page.svelte b/src/routes/fitness/[nutrition=fitnessNutrition]/[[date=fitnessDate]]/+page.svelte index 6d1dbc3..39dbf78 100644 --- a/src/routes/fitness/[nutrition=fitnessNutrition]/[[date=fitnessDate]]/+page.svelte +++ b/src/routes/fitness/[nutrition=fitnessNutrition]/[[date=fitnessDate]]/+page.svelte @@ -394,6 +394,9 @@ return { calories, protein, fat, carbs, fiber, sugars, saturatedFat, micros, aminos }; }); + // Atwater-derived calories (consistent with macro goals which use 4/9/4) + const atwaterCalories = $derived(dayTotals.protein * 4 + dayTotals.fat * 9 + dayTotals.carbs * 4); + // Macro percentages by calorie contribution const macroPercent = $derived.by(() => { const proteinCal = dayTotals.protein * 4; @@ -499,8 +502,9 @@ // Net calorie balance: effective goal (includes exercise) - eaten - const calorieBalance = $derived(effectiveCalorieGoal ? (effectiveCalorieGoal - dayTotals.calories) : 0); - const calorieProgressRaw = $derived(effectiveCalorieGoal ? dayTotals.calories / effectiveCalorieGoal * 100 : 0); + // Use Atwater-derived calories so the ring and macro bars always agree + const calorieBalance = $derived(effectiveCalorieGoal ? (effectiveCalorieGoal - atwaterCalories) : 0); + const calorieProgressRaw = $derived(effectiveCalorieGoal ? atwaterCalories / effectiveCalorieGoal * 100 : 0); const calorieProgress = $derived(Math.min(calorieProgressRaw, 100)); const calorieOverflow = $derived(Math.max(calorieProgressRaw - 100, 0)); @@ -1178,7 +1182,7 @@