Skip to content

Commit c25950f

Browse files
committed
Simplify BulkMarkNotificationMessagesFailed
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent c1a3010 commit c25950f

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

coderd/database/queries.sql.go

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/notifications.sql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ FROM acquired nm
8686
JOIN notification_templates nt ON nm.notification_template_id = nt.id;
8787

8888
-- name: BulkMarkNotificationMessagesFailed :execrows
89-
WITH new_values AS (SELECT UNNEST(@ids::uuid[]) AS id,
90-
UNNEST(@failed_ats::timestamptz[]) AS failed_at,
91-
UNNEST(@statuses::notification_message_status[]) AS status,
92-
UNNEST(@status_reasons::text[]) AS status_reason)
9389
UPDATE notification_messages
9490
SET updated_at = subquery.failed_at,
9591
attempt_count = attempt_count + 1,
@@ -101,8 +97,10 @@ SET updated_at = subquery.failed_at,
10197
next_retry_after = CASE
10298
WHEN (attempt_count + 1 < @max_attempts::int)
10399
THEN NOW() + CONCAT(@retry_interval::int, ' seconds')::interval END
104-
FROM (SELECT id, status, status_reason, failed_at
105-
FROM new_values) AS subquery
100+
FROM (SELECT UNNEST(@ids::uuid[]) AS id,
101+
UNNEST(@failed_ats::timestamptz[]) AS failed_at,
102+
UNNEST(@statuses::notification_message_status[]) AS status,
103+
UNNEST(@status_reasons::text[]) AS status_reason) AS subquery
106104
WHERE notification_messages.id = subquery.id;
107105

108106
-- name: BulkMarkNotificationMessagesSent :execrows

0 commit comments

Comments
 (0)