mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(coderd): humanize duration on notifications (#14333)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/xerrors"
|
||||
@@ -1064,6 +1065,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if initiatorErr == nil && tmplErr == nil {
|
||||
dormantTime := dbtime.Now().Add(time.Duration(tmpl.TimeTilDormant))
|
||||
_, err = api.NotificationsEnqueuer.Enqueue(
|
||||
ctx,
|
||||
workspace.OwnerID,
|
||||
@@ -1071,7 +1073,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) {
|
||||
map[string]string{
|
||||
"name": workspace.Name,
|
||||
"reason": "a " + initiator.Username + " request",
|
||||
"timeTilDormant": time.Duration(tmpl.TimeTilDormant).String(),
|
||||
"timeTilDormant": humanize.Time(dormantTime),
|
||||
},
|
||||
"api",
|
||||
workspace.ID,
|
||||
|
||||
Reference in New Issue
Block a user