From c19f4a8500d49f8eb6f2c095ef2f089ac1db513f Mon Sep 17 00:00:00 2001 From: pdewey
Date: Fri, 23 Jan 2026 22:58:02 -0500 Subject: [PATCH] fix: sum pour water amounts when water amount not set On brew view page, if WaterAmount is 0 but pours exist, calculate and display the sum of all pour water amounts. --- internal/bff/render.go | 13 ++++++++++++- templates/partials/feed.tmpl | 2 +- templates/partials/profile_content.tmpl | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/bff/render.go b/internal/bff/render.go index cb58d28..a4cfe75 100644 --- a/internal/bff/render.go +++ b/internal/bff/render.go @@ -247,8 +247,19 @@ func RenderBrewView(w http.ResponseWriter, brew *models.Brew, isAuthenticated bo return err } + // If water amount is not set but pours exist, sum the pours + displayBrew := brew + if brew.WaterAmount == 0 && len(brew.Pours) > 0 { + // Create a copy to avoid modifying the original + brewCopy := *brew + for _, pour := range brew.Pours { + brewCopy.WaterAmount += pour.WaterAmount + } + displayBrew = &brewCopy + } + brewData := &BrewData{ - Brew: brew, + Brew: displayBrew, PoursJSON: PoursToJSON(brew.Pours), } diff --git a/templates/partials/feed.tmpl b/templates/partials/feed.tmpl index 3199233..68be018 100644 --- a/templates/partials/feed.tmpl +++ b/templates/partials/feed.tmpl @@ -50,7 +50,7 @@ {{if and .Brew.Bean.Roaster .Brew.Bean.Roaster.Name}}