chore: set closed_at and resolved_at only once in conversations, on subsequent updates they are not to be updated again and again to the current time

- Remove unncessary websocket update due to this change
This commit is contained in:
Abhinav Raut
2025-03-12 03:21:13 +05:30
parent 4bef3e80a2
commit 2fdcf68a22
2 changed files with 3 additions and 10 deletions
-7
View File
@@ -574,13 +574,6 @@ func (c *Manager) UpdateConversationStatus(uuid string, statusID int, status, sn
// Broadcast updates using websocket.
c.BroadcastConversationUpdate(uuid, "status", status)
if status == models.StatusResolved {
c.BroadcastConversationUpdate(uuid, "resolved_at", time.Now().Format(time.RFC3339))
}
if status == models.StatusClosed {
c.BroadcastConversationUpdate(uuid, "closed_at", time.Now().Format(time.RFC3339))
c.BroadcastConversationUpdate(uuid, "resolved_at", time.Now().Format(time.RFC3339))
}
return nil
}
+3 -3
View File
@@ -197,9 +197,9 @@ WHERE uuid = $1;
-- name: update-conversation-status
UPDATE conversations
SET status_id = (SELECT id FROM conversation_statuses WHERE name = $2),
resolved_at = CASE WHEN $2 IN ('Resolved', 'Closed') THEN NOW() ELSE resolved_at END,
closed_at = CASE WHEN $2 = 'Closed' THEN NOW() ELSE closed_at END,
snoozed_until = CASE WHEN $2 = 'Snoozed' THEN $3::timestamptz ELSE NULL END,
resolved_at = COALESCE(resolved_at, CASE WHEN $2 IN ('Resolved', 'Closed') THEN NOW() END),
closed_at = COALESCE(closed_at, CASE WHEN $2 = 'Closed' THEN NOW() END),
snoozed_until = CASE WHEN $2 = 'Snoozed' THEN $3::timestamptz ELSE snoozed_until END,
updated_at = NOW()
WHERE uuid = $1;