From 35fe0ad6b60640e86add740c3b49dff05c75a240 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 2 Oct 2023 21:54:01 +0200
Subject: [PATCH] Improve calories counter.

---
 calories.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/calories.py b/calories.py
index 54fb64e..7a4846a 100644
--- a/calories.py
+++ b/calories.py
@@ -296,12 +296,12 @@ class MyServer(BaseHTTPRequestHandler):
                     "</tr>" % (db.eatables_selection(c.eatable_key), c.unit_count, r["cals"], r["sugar"])
         day_rows = ""
         for date, day in db.days.items():
-            day_rows += "<tr>"\
+            day_rows = "<tr>"\
                     "<td><input name=\"day_date\" type=\"hidden\" value=\"%s\" />%s</td>"\
                     "<td><input name=\"day_cals\" type=\"hidden\" step=\"0.1\" min=\"0\" value=\"%.1f\" />%.1f</td>"\
                     "<td><input name=\"day_sugar\" type=\"hidden\" step=\"0.1\" min=\"0\" value=\"%.1f\" />%.1f</td>"\
-                    "</tr>" % (date, date[:10], day.calories, day.calories, day.sugar_g, day.sugar_g)
-        day_rows += "<tr>"\
+                    "</tr>" % (date, date[:10], day.calories, day.calories, day.sugar_g, day.sugar_g) + day_rows
+        day_rows = "<tr>"\
                 "<th>today:</th><th></th><th></th><th>archive?</th>"\
                 "</tr>"\
                 "<tr>"\
@@ -309,7 +309,7 @@ class MyServer(BaseHTTPRequestHandler):
                 "<td><input name=\"new_day_cals\" type=\"hidden\" value=\"%.1f\" readonly />%.1f</td>"\
                 "<td><input name=\"new_day_sugar\" type=\"hidden\" value=\"%.1f\" readonly />%.1f</td>"\
                 "<td><input name=\"archive_day\" type=\"checkbox\" /></td>"\
-                "</tr>" % (db.today_date, db.today.calories, db.today.calories, db.today.sugar_g, db.today.sugar_g)
+                "</tr>" % (db.today_date, db.today.calories, db.today.calories, db.today.sugar_g, db.today.sugar_g) + day_rows
         page = build_page(eatables, consumptions, db.eatables_selection(), day_rows)
         self.wfile.write(bytes(page, "utf-8"))
 
-- 
2.30.2