From 92aea89b7456f3ea008be8cbf20f9d2e54af051b Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 8 Sep 2026 11:53:31 -0400 Subject: [PATCH] User Activity report: filter 'Last Activity' by the selected date range (#52) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last_activity subquery had no WHERE clause on the report's date-range filter, so it always showed true all-time last activity even when the page was filtered to e.g. "last 7 days" — inconsistent with every other column on the same report. Added the same DATE(created_at) BETWEEN ? AND ? clause used by the report's other subqueries. Verified against a local MariaDB instance: an out-of-range audit_log row is correctly excluded from last_activity once the filter is applied. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01MGDKHiU5RJdo3dqQUDow3X --- index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 119f68f..d5982c0 100644 --- a/index.php +++ b/index.php @@ -391,13 +391,16 @@ switch (true) { LEFT JOIN ( SELECT user_id, MAX(created_at) as last_activity FROM audit_log + WHERE DATE(created_at) BETWEEN ? AND ? GROUP BY user_id ) al ON u.user_id = al.user_id ORDER BY tickets_created DESC, tickets_resolved DESC"; $stmt = $conn->prepare($sql); $stmt->bind_param( - 'ssssssss', + 'ssssssssss', + $dateRange['from'], + $dateRange['to'], $dateRange['from'], $dateRange['to'], $dateRange['from'],