From bc88ba36125e4e93d16fbade653ae66b933168fb Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 5 Apr 2026 11:32:02 -0400 Subject: [PATCH] Fix notifications 500 (audit_id column), smart resolution time units - notifications.php: audit_log PK is audit_id not log_id; alias all three queries with audit_id AS log_id to fix 500 error - DashboardView: avg resolution time now picks best unit automatically (min < 1h, hr < 48h, days < 14d, wks otherwise) with full hours shown in title tooltip; adds lt-stat-unit CSS for the suffix Co-Authored-By: Claude Sonnet 4.6 --- api/notifications.php | 6 +++--- assets/css/dashboard.css | 8 ++++++++ views/DashboardView.php | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/api/notifications.php b/api/notifications.php index aa23696..f3afd22 100644 --- a/api/notifications.php +++ b/api/notifications.php @@ -45,7 +45,7 @@ $myUsername = $currentUser['username'] ?? ''; // Query 1: Tickets assigned to me (events from other users) $assignSql = "SELECT - al.log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, + al.audit_id AS log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, COALESCE(u.display_name, u.username, 'System') AS actor_name FROM audit_log al LEFT JOIN users u ON al.user_id = u.user_id @@ -88,7 +88,7 @@ $stmt->close(); // Step B: fetch recent comment audit events not by the current user $commentSql = "SELECT - al.log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, + al.audit_id AS log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, COALESCE(u.display_name, u.username, 'System') AS actor_name FROM audit_log al LEFT JOIN users u ON al.user_id = u.user_id @@ -118,7 +118,7 @@ foreach ($rawCommentRows as $rawRow) { // Query 3: Status changes on watched tickets (from other users) $statusSql = "SELECT DISTINCT - al.log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, + al.audit_id AS log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at, COALESCE(u.display_name, u.username, 'System') AS actor_name FROM audit_log al LEFT JOIN users u ON al.user_id = u.user_id diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css index d3d7947..4a5dcaf 100644 --- a/assets/css/dashboard.css +++ b/assets/css/dashboard.css @@ -8,6 +8,14 @@ margin-bottom: 1rem; } +/* Unit suffix on resolution time stat (smaller, muted) */ +.lt-stat-unit { + font-size: 0.65em; + font-weight: 500; + margin-left: 0.15em; + opacity: 0.75; +} + /* Priority row highlights */ .lt-row-critical td { background: rgba(255, 77, 77, 0.04); diff --git a/views/DashboardView.php b/views/DashboardView.php index 6f50cac..0737710 100644 --- a/views/DashboardView.php +++ b/views/DashboardView.php @@ -162,10 +162,25 @@ include __DIR__ . '/layout_header.php'; -
+ 0 ? number_format($avgHours, 1) . ' hours' : 'No data'; + ?> +
-
h
+
Avg Resolution