Skip to content

Commit 44a0e9f

Browse files
committed
Small touch-ups
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 9f1d6b3 commit 44a0e9f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

coderd/database/queries.sql.go

Lines changed: 4 additions & 2 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ FROM acquired nm
8989

9090
-- name: BulkMarkNotificationMessagesFailed :execrows
9191
UPDATE notification_messages
92-
SET updated_at = subquery.failed_at,
92+
SET queued_seconds = 0,
93+
updated_at = subquery.failed_at,
9394
attempt_count = attempt_count + 1,
9495
status = CASE
9596
WHEN attempt_count + 1 < @max_attempts::int THEN subquery.status
@@ -107,7 +108,8 @@ WHERE notification_messages.id = subquery.id;
107108

108109
-- name: BulkMarkNotificationMessagesSent :execrows
109110
UPDATE notification_messages
110-
SET updated_at = new_values.sent_at,
111+
SET queued_seconds = 0,
112+
updated_at = new_values.sent_at,
111113
attempt_count = attempt_count + 1,
112114
status = 'sent'::notification_message_status,
113115
status_reason = NULL,

coderd/notifications/metrics_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ func TestMetrics(t *testing.T) {
9292
notifications.ResultPermFail: 1, // 1 permanent failure after retries exhausted.
9393
}
9494

95-
var target *float64
95+
var match string
9696
for result, val := range results {
9797
seriesFP := fingerprintLabels(notifications.LabelMethod, string(method), notifications.LabelTemplateID, template.String(), notifications.LabelResult, result)
9898
if !hasMatchingFingerprint(metric, seriesFP) {
9999
continue
100100
}
101101

102-
target = &val
102+
match = result
103103

104104
if debug {
105105
t.Logf("coderd_notifications_dispatch_attempts_total{result=%q} == %v: %v", result, val, metric.Counter.GetValue())
@@ -109,16 +109,14 @@ func TestMetrics(t *testing.T) {
109109
}
110110

111111
// Could not find a matching series.
112-
if target == nil {
112+
if match == "" {
113113
assert.Failf(t, "found unexpected series %q", series)
114114
return false
115115
}
116116

117-
if metric.Counter.GetValue() != *target {
118-
return false
119-
}
120-
121-
return true
117+
// nolint:forcetypeassert // Already checked above.
118+
target := results[match]
119+
return metric.Counter.GetValue() == target
122120
},
123121
"coderd_notifications_retry_count": func(metric *dto.Metric, series string) bool {
124122
assert.Truef(t, hasMatchingFingerprint(metric, methodTemplateFP), "found unexpected series %q", series)

0 commit comments

Comments
 (0)