refactor(coderd/database): split Time and Now into dbtime package (#9482)

Ref: #9380
This commit is contained in:
Mathias Fredriksson
2023-09-01 16:50:12 +00:00
committed by GitHub
parent 702b064cac
commit 19d7da3d24
89 changed files with 466 additions and 390 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ import (
"cdr.dev/slog/sloggers/sloghuman"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/codersdk/agentsdk"
)
@@ -137,7 +138,7 @@ func (b *Batcher) Add(
b.mu.Lock()
defer b.mu.Unlock()
now = database.Time(now)
now = dbtime.Time(now)
b.buf.ID = append(b.buf.ID, uuid.New())
b.buf.CreatedAt = append(b.buf.CreatedAt, now)
+2 -1
View File
@@ -13,6 +13,7 @@ import (
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbgen"
"github.com/coder/coder/v2/coderd/database/dbtestutil"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/cryptorand"
@@ -46,7 +47,7 @@ func TestBatchStats(t *testing.T) {
// Given: no data points are added for workspace
// When: it becomes time to report stats
t1 := database.Now()
t1 := dbtime.Now()
// Signal a tick and wait for a flush to complete.
tick <- t1
f := <-flushed