From 857795165ab9a0eee64a9d6849a7ac99356cccc6 Mon Sep 17 00:00:00 2001 From: dsutanto Date: Fri, 3 Jul 2026 13:16:38 +0700 Subject: [PATCH] Excel --- counter_dashboard.py | 20 +++++++++++--------- templates/dashboard.html | 33 ++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/counter_dashboard.py b/counter_dashboard.py index 47b13f2..89fce8f 100644 --- a/counter_dashboard.py +++ b/counter_dashboard.py @@ -392,11 +392,11 @@ def export_daily_xlsx(): cur = conn.cursor() cur.execute( """ - SELECT counting_date, total_count, total_batches, - ROUND(CAST(total_count AS FLOAT) / NULLIF(total_batches, 0), 1) as avg_per_batch - FROM daily_summaries + SELECT counting_date, batch_number, count, start_time, end_time, + ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes + FROM batches WHERE counting_date >= ? - ORDER BY counting_date ASC + ORDER BY counting_date ASC, batch_number ASC """, (date_from,), ) @@ -405,14 +405,16 @@ def export_daily_xlsx(): wb = Workbook() ws = wb.active - ws.title = "Daily Records" - _style_header(ws, [("A", "Date"), ("B", "Total Count"), ("C", "Total Batches"), ("D", "Avg per Batch")]) + ws.title = "Batch Details" + _style_header(ws, [("A", "Date"), ("B", "Batch #"), ("C", "Count"), ("D", "Start Time"), ("E", "End Time"), ("F", "Duration (min)")]) for r_idx, row in enumerate(rows, 2): ws.cell(row=r_idx, column=1, value=row["counting_date"]) - ws.cell(row=r_idx, column=2, value=row["total_count"]) - ws.cell(row=r_idx, column=3, value=row["total_batches"]) - ws.cell(row=r_idx, column=4, value=row["avg_per_batch"] or 0) + ws.cell(row=r_idx, column=2, value=row["batch_number"]) + ws.cell(row=r_idx, column=3, value=row["count"]) + ws.cell(row=r_idx, column=4, value=row["start_time"]) + ws.cell(row=r_idx, column=5, value=row["end_time"]) + ws.cell(row=r_idx, column=6, value=row["duration_minutes"] or 0) _auto_width(ws) filename = f"daily_records_{datetime.now().strftime('%Y%m%d_%H%M%S')}.xlsx" diff --git a/templates/dashboard.html b/templates/dashboard.html index dcd0e60..6aae9e0 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -707,7 +707,7 @@
- +
@@ -1008,6 +1008,11 @@ async function loadAllDates() { } } +function resetFilter() { + document.getElementById('date-filter').value = ''; + loadAllDates(); +} + function renderDailyTable(dates) { const tbody = document.getElementById('daily-table-body'); const currentDate = document.getElementById('current-date').textContent; @@ -1179,12 +1184,26 @@ function hideVideoError() {