mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor(coderd/database): split Time and Now into dbtime package (#9482)
Ref: #9380
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtime"
|
||||
"github.com/coder/coder/v2/coderd/database/pubsub"
|
||||
"github.com/coder/coder/v2/provisionersdk"
|
||||
)
|
||||
@@ -274,7 +275,7 @@ func unhangJob(ctx context.Context, log slog.Logger, db database.Store, pub pubs
|
||||
insertParams := database.InsertProvisionerJobLogsParams{
|
||||
JobID: job.ID,
|
||||
}
|
||||
now := database.Now()
|
||||
now := dbtime.Now()
|
||||
for i, msg := range HungJobLogMessages {
|
||||
// Set the created at in a way that ensures each message has
|
||||
// a unique timestamp so they will be sorted correctly.
|
||||
@@ -291,7 +292,7 @@ func unhangJob(ctx context.Context, log slog.Logger, db database.Store, pub pubs
|
||||
lowestLogID = newLogs[0].ID
|
||||
|
||||
// Mark the job as failed.
|
||||
now = database.Now()
|
||||
now = dbtime.Now()
|
||||
err = db.UpdateProvisionerJobWithCompleteByID(ctx, database.UpdateProvisionerJobWithCompleteByIDParams{
|
||||
ID: job.ID,
|
||||
UpdatedAt: now,
|
||||
@@ -334,7 +335,7 @@ func unhangJob(ctx context.Context, log slog.Logger, db database.Store, pub pubs
|
||||
if err == nil {
|
||||
err = db.UpdateWorkspaceBuildByID(ctx, database.UpdateWorkspaceBuildByIDParams{
|
||||
ID: build.ID,
|
||||
UpdatedAt: database.Now(),
|
||||
UpdatedAt: dbtime.Now(),
|
||||
ProvisionerState: prevBuild.ProvisionerState,
|
||||
Deadline: time.Time{},
|
||||
MaxDeadline: time.Time{},
|
||||
|
||||
Reference in New Issue
Block a user