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
+3 -2
View File
@@ -12,6 +12,7 @@ import (
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbtime"
)
const (
@@ -43,7 +44,7 @@ func newStatsReportFromSignedToken(token SignedToken) StatsReport {
AccessMethod: token.AccessMethod,
SlugOrPort: token.AppSlugOrPort,
SessionID: uuid.New(),
SessionStartedAt: database.Now(),
SessionStartedAt: dbtime.Now(),
Requests: 1,
}
}
@@ -294,7 +295,7 @@ func (sc *StatsCollector) rollup(now time.Time) []StatsReport {
// Report an end time for incomplete sessions, it will
// be updated later. This ensures that data in the DB
// will have an end time even if the service is stopped.
r.SessionEndedAt = now.UTC() // Use UTC like database.Now().
r.SessionEndedAt = now.UTC() // Use UTC like dbtime.Now().
}
report = append(report, r) // Report it (ended or incomplete).
if stat.SessionEndedAt.IsZero() {