From 7745e1ed865e86f59945da2c04aab2c5aa6c4cec Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Mon, 9 Feb 2026 17:20:01 -0800 Subject: [PATCH] Fix pending task count to exclude completed tasks The PendingTaskCount subquery was only checking ClaimedByUserID = 0 but not CompletedOn IS NULL, causing completed-but-unclaimed tasks to show up in the business selection screen count. Co-Authored-By: Claude Opus 4.5 --- api/workers/myBusinesses.cfm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/workers/myBusinesses.cfm b/api/workers/myBusinesses.cfm index 9e0c4ca..aa30dd5 100644 --- a/api/workers/myBusinesses.cfm +++ b/api/workers/myBusinesses.cfm @@ -41,7 +41,7 @@ MIN(e.StatusID) AS StatusID, MAX(e.IsActive) AS IsActive, b.Name AS Name, - (SELECT COUNT(*) FROM Tasks t WHERE t.BusinessID = e.BusinessID AND t.ClaimedByUserID = 0) AS PendingTaskCount + (SELECT COUNT(*) FROM Tasks t WHERE t.BusinessID = e.BusinessID AND t.ClaimedByUserID = 0 AND t.CompletedOn IS NULL) AS PendingTaskCount FROM Employees e INNER JOIN Businesses b ON b.ID = e.BusinessID WHERE e.UserID = ? AND e.IsActive = b'1'