Skip to content

Commit 8d3acc9

Browse files
committed
Use dbtime
1 parent ad12096 commit 8d3acc9

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

coderd/autobuild/lifecycle_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
324324
}
325325
}
326326
if shouldNotifyDormancy {
327-
dormantTime := time.Now().Add(time.Duration(tmpl.TimeTilDormant))
327+
dormantTime := dbtime.Now().Add(time.Duration(tmpl.TimeTilDormant))
328328
_, err = e.notificationsEnqueuer.Enqueue(
329329
e.ctx,
330330
ws.OwnerID,

coderd/notifications/notifications_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,19 @@ func TestNotificationTemplatesCanRender(t *testing.T) {
720720
},
721721
},
722722
},
723+
{
724+
name: "TemplateWorkspaceMarkedForDeletionInOneWeek",
725+
id: notifications.TemplateWorkspaceMarkedForDeletion,
726+
payload: types.MessagePayload{
727+
UserName: "bobby",
728+
Labels: map[string]string{
729+
"name": "bobby-workspace",
730+
"reason": "template updated to new dormancy policy",
731+
"dormancyHours": "168", // 168 hours = 7 days = 1 week
732+
"timeTilDormant": "1 week",
733+
},
734+
},
735+
},
723736
{
724737
name: "TemplateUserAccountCreated",
725738
id: notifications.TemplateUserAccountCreated,

coderd/workspaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) {
10561056
}
10571057

10581058
if initiatorErr == nil && tmplErr == nil {
1059-
dormantTime := time.Now().Add(time.Duration(tmpl.TimeTilDormant))
1059+
dormantTime := dbtime.Now().Add(time.Duration(tmpl.TimeTilDormant))
10601060
_, err = api.NotificationsEnqueuer.Enqueue(
10611061
ctx,
10621062
workspace.OwnerID,

enterprise/coderd/schedule/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (s *EnterpriseTemplateScheduleStore) Set(ctx context.Context, db database.S
206206
}
207207

208208
for _, ws := range markedForDeletion {
209-
dormantTime := time.Now().Add(opts.TimeTilDormantAutoDelete)
209+
dormantTime := dbtime.Now().Add(opts.TimeTilDormantAutoDelete)
210210
_, err = s.enqueuer.Enqueue(
211211
ctx,
212212
ws.OwnerID,

0 commit comments

Comments
 (0)