Skip to content

Commit 5215c92

Browse files
committed
WIP
1 parent 8f634a4 commit 5215c92

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,8 +3002,8 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
30023002
return out, nil
30033003
}
30043004

3005-
func (q *FakeQuerier) GetNotificationReportGeneratorLogByTemplate(_ context.Context, arg uuid.UUID) (database.NotificationReportGeneratorLog, error) {
3006-
err := validateDatabaseType(arg)
3005+
func (q *FakeQuerier) GetNotificationReportGeneratorLogByTemplate(_ context.Context, templateID uuid.UUID) (database.NotificationReportGeneratorLog, error) {
3006+
err := validateDatabaseType(templateID)
30073007
if err != nil {
30083008
return database.NotificationReportGeneratorLog{}, err
30093009
}
@@ -3012,7 +3012,7 @@ func (q *FakeQuerier) GetNotificationReportGeneratorLogByTemplate(_ context.Cont
30123012
defer q.mutex.RUnlock()
30133013

30143014
for _, record := range q.notificationReportGeneratorLogs {
3015-
if record.UserID == arg.UserID && record.NotificationTemplateID == arg.NotificationTemplateID {
3015+
if record.NotificationTemplateID == templateID {
30163016
return record, nil
30173017
}
30183018
}

coderd/database/queries/notifications.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ SELECT
182182
FROM
183183
notification_report_generator_logs
184184
WHERE
185-
notification_template_id = $1;
185+
notification_template_id = @template_id::uuid;
186186

187187
-- name: UpsertNotificationReportGeneratorLog :exec
188188
-- Insert or update notification report generator logs with recent activity.

coderd/notifications/reports/generator.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ func reportFailedWorkspaceBuilds(ctx context.Context, logger slog.Logger, db dat
137137
}
138138

139139
for _, templateAdmin := range templateAdmins {
140-
reportLog, err := db.GetNotificationReportGeneratorLogByTemplate(ctx, database.GetNotificationReportGeneratorLogByTemplateParams{
141-
UserID: templateAdmin.ID,
142-
NotificationTemplateID: notifications.TemplateWorkspaceBuildsFailedReport,
143-
})
140+
reportLog, err := db.GetNotificationReportGeneratorLogByTemplate(ctx, notifications.TemplateWorkspaceBuildsFailedReport)
144141
if err != nil && !xerrors.Is(err, sql.ErrNoRows) { // sql.ErrNoRows: report not generated yet
145142
continue
146143
}
@@ -178,7 +175,6 @@ func reportFailedWorkspaceBuilds(ctx context.Context, logger slog.Logger, db dat
178175

179176
for u := range processedUsers {
180177
err = db.UpsertNotificationReportGeneratorLog(ctx, database.UpsertNotificationReportGeneratorLogParams{
181-
UserID: u,
182178
NotificationTemplateID: notifications.TemplateWorkspaceBuildsFailedReport,
183179
LastGeneratedAt: dbtime.Time(now).UTC(),
184180
})

0 commit comments

Comments
 (0)