From d1f08ce035a208d1474863217981aec0d52b0e2d Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Wed, 5 Mar 2025 04:24:06 +0530 Subject: [PATCH] fix: handle null user last active time when marking agents offline. --- internal/user/queries.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/user/queries.sql b/internal/user/queries.sql index fc507926..d9192d75 100644 --- a/internal/user/queries.sql +++ b/internal/user/queries.sql @@ -97,7 +97,10 @@ WHERE id = $1; -- name: update-inactive-offline UPDATE users SET availability_status = 'offline' -WHERE last_active_at < now() - interval '5 minutes' and availability_status != 'offline'; +WHERE +type = 'agent' +AND (last_active_at IS NULL OR last_active_at < NOW() - INTERVAL '5 minutes') +AND availability_status != 'offline'; -- name: get-permissions SELECT DISTINCT unnest(r.permissions)