04/23 Enhance app functionalities 2

This commit is contained in:
2026-04-23 17:32:44 -04:00
parent f4eea48e4d
commit 58c6218c14
8 changed files with 609 additions and 28 deletions
+19 -1
View File
@@ -111,7 +111,14 @@ def _build_html_report() -> str:
rows = stats.get("user_stats", [])
table_rows = ""
skipped_no_shift = 0
for r in rows:
total = int(r.get("total_sites") or 0)
# Skip users with no shifts scheduled today — they have no expected
# work for this day and showing them as "0 / 0 — 0%" is misleading.
if total == 0:
skipped_no_shift += 1
continue
pct = float(r.get("pct_complete") or 0)
color = "#388e3c" if pct >= 100 else "#f57c00" if pct > 0 else "#d32f2f"
table_rows += (
@@ -119,11 +126,21 @@ def _build_html_report() -> str:
f"<td style='padding:8px 12px'>{r['username']}</td>"
f"<td style='padding:8px 12px'>{r['full_name'] or ''}</td>"
f"<td style='padding:8px 12px;text-align:center'>{int(r['checked_count'] or 0)}</td>"
f"<td style='padding:8px 12px;text-align:center'>{int(r['total_sites'] or 0)}</td>"
f"<td style='padding:8px 12px;text-align:center'>{total}</td>"
f"<td style='padding:8px 12px;text-align:center;"
f"color:{color};font-weight:bold'>{pct:.0f}%</td>"
f"</tr>"
)
if not table_rows:
table_rows = (
"<tr><td colspan='5' style='padding:12px;color:#6b6b80;"
"text-align:center'>No users with active shifts today.</td></tr>"
)
no_shift_note = (
f"<p style='color:#6b6b80;font-size:11px'>"
f"{skipped_no_shift} user(s) had no shifts scheduled today and are "
f"excluded from this report.</p>"
) if skipped_no_shift else ""
return f"""
<html><body style="font-family:Segoe UI,Arial,sans-serif;color:#1a1a2e">
@@ -142,6 +159,7 @@ def _build_html_report() -> str:
</thead>
<tbody>{table_rows}</tbody>
</table>
{no_shift_note}
<p style="color:#6b6b80;font-size:12px;margin-top:24px">
Sent automatically by Website Checker at {datetime.datetime.now().strftime('%H:%M')}.
</p>