Skip to content

feat: create database tables and queries for notifications #13536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify BulkMarkNotificationMessagesFailed
Signed-off-by: Danny Kopping <danny@coder.com>
  • Loading branch information
dannykopping committed Jun 28, 2024
commit c25950f11533d8127c6fead3bc6f2890c6b68216
10 changes: 4 additions & 6 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions coderd/database/queries/notifications.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ FROM acquired nm
JOIN notification_templates nt ON nm.notification_template_id = nt.id;

-- name: BulkMarkNotificationMessagesFailed :execrows
WITH new_values AS (SELECT UNNEST(@ids::uuid[]) AS id,
UNNEST(@failed_ats::timestamptz[]) AS failed_at,
UNNEST(@statuses::notification_message_status[]) AS status,
UNNEST(@status_reasons::text[]) AS status_reason)
UPDATE notification_messages
SET updated_at = subquery.failed_at,
attempt_count = attempt_count + 1,
Expand All @@ -101,8 +97,10 @@ SET updated_at = subquery.failed_at,
next_retry_after = CASE
WHEN (attempt_count + 1 < @max_attempts::int)
THEN NOW() + CONCAT(@retry_interval::int, ' seconds')::interval END
FROM (SELECT id, status, status_reason, failed_at
FROM new_values) AS subquery
FROM (SELECT UNNEST(@ids::uuid[]) AS id,
UNNEST(@failed_ats::timestamptz[]) AS failed_at,
UNNEST(@statuses::notification_message_status[]) AS status,
UNNEST(@status_reasons::text[]) AS status_reason) AS subquery
WHERE notification_messages.id = subquery.id;

-- name: BulkMarkNotificationMessagesSent :execrows
Expand Down
Loading