Skip to content

Commit 8d6b74d

Browse files
committed
Merge branch 'main' into org-switcher
2 parents 8ad9881 + a8a0be9 commit 8d6b74d

File tree

7 files changed

+26
-0
lines changed

7 files changed

+26
-0
lines changed

coderd/agentapi/activitybump.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func ActivityBumpWorkspace(ctx context.Context, log slog.Logger, db database.Sto
4141
// low priority operations fail first.
4242
ctx, cancel := context.WithTimeout(ctx, time.Second*15)
4343
defer cancel()
44+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
4445
err := db.ActivityBumpWorkspace(ctx, database.ActivityBumpWorkspaceParams{
4546
NextAutostart: nextAutostart.UTC(),
4647
WorkspaceID: workspaceID,

coderd/agentapi/stats.go

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func (a *StatsAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateStatsR
102102
return nil
103103
})
104104
errGroup.Go(func() error {
105+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
105106
err := a.Database.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{
106107
ID: workspace.ID,
107108
LastUsedAt: now,

coderd/batchstats/batcher.go

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (b *Batcher) flush(ctx context.Context, forced bool, reason string) {
240240
b.buf.ConnectionsByProto = payload
241241
}
242242

243+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
243244
err = b.store.InsertWorkspaceAgentStats(ctx, *b.buf)
244245
elapsed := time.Since(start)
245246
if err != nil {

coderd/workspaceagents.go

+1
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
12441244
})
12451245
if req.SessionCount() > 0 {
12461246
errGroup.Go(func() error {
1247+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
12471248
err := api.Database.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{
12481249
ID: workspace.ID,
12491250
LastUsedAt: now,

coderd/workspaceusage/tracker.go

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func (tr *Tracker) flush(now time.Time) {
130130
authCtx := dbauthz.AsSystemRestricted(ctx)
131131
tr.flushLock.Lock()
132132
defer tr.flushLock.Unlock()
133+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
133134
if err := tr.s.BatchUpdateWorkspaceLastUsedAt(authCtx, database.BatchUpdateWorkspaceLastUsedAtParams{
134135
LastUsedAt: now,
135136
IDs: ids,

enterprise/coderd/schedule/template.go

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (s *EnterpriseTemplateScheduleStore) Set(ctx context.Context, db database.S
169169
}
170170

171171
if opts.UpdateWorkspaceLastUsedAt {
172+
// nolint:gocritic // (#13146) Will be moved soon as part of refactor.
172173
err = tx.UpdateTemplateWorkspacesLastUsedAt(ctx, database.UpdateTemplateWorkspacesLastUsedAtParams{
173174
TemplateID: tpl.ID,
174175
LastUsedAt: dbtime.Now(),

scripts/rules.go

+20
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,23 @@ func withTimezoneUTC(m dsl.Matcher) {
467467
).Report(`Setting database timezone to UTC may mask timezone-related bugs.`).
468468
At(m["tz"])
469469
}
470+
471+
// workspaceActivity ensures that updating workspace activity is only done in the workspaceapps package.
472+
//
473+
//nolint:unused,deadcode,varnamelen
474+
func workspaceActivity(m dsl.Matcher) {
475+
m.Import("github.com/coder/coder/v2/coderd/database")
476+
m.Match(
477+
`$_.ActivityBumpWorkspace($_, $_)`,
478+
`$_.UpdateWorkspaceLastUsedAt($_, $_)`,
479+
`$_.BatchUpdateWorkspaceLastUsedAt($_, $_)`,
480+
`$_.UpdateTemplateWorkspacesLastUsedAt($_, $_)`,
481+
`$_.InsertWorkspaceAgentStats($_, $_)`,
482+
`$_.InsertWorkspaceAppStats($_, $_)`,
483+
).Where(
484+
!m.File().PkgPath.Matches(`workspaceapps`) &&
485+
!m.File().PkgPath.Matches(`dbauthz$`) &&
486+
!m.File().PkgPath.Matches(`dbgen$`) &&
487+
!m.File().Name.Matches(`_test\.go$`),
488+
).Report("Updating workspace activity should always be done in the workspaceapps package.")
489+
}

0 commit comments

Comments
 (0)