Skip to content

Commit 082a599

Browse files
committed
fix
1 parent c8bc07e commit 082a599

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

coderd/agentapi/stats_test.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func TestUpdateStates(t *testing.T) {
108108
Database: dbM,
109109
Pubsub: ps,
110110
StatsBatcher: batcher,
111+
UsageTracker: workspacestats.NewTracker(dbM),
111112
TemplateScheduleStore: templateScheduleStorePtr(templateScheduleStore),
112113
UpdateAgentMetricsFn: func(ctx context.Context, labels prometheusmetrics.AgentMetricLabels, metrics []*agentproto.Stats_Metric) {
113114
updateAgentMetricsFnCalled = true
@@ -132,21 +133,15 @@ func TestUpdateStates(t *testing.T) {
132133
TemplateName: template.Name,
133134
}, nil)
134135

136+
// User gets fetched to hit the UpdateAgentMetricsFn.
137+
dbM.EXPECT().GetUserByID(gomock.Any(), user.ID).Return(user, nil)
138+
135139
// We expect an activity bump because ConnectionCount > 0.
136140
dbM.EXPECT().ActivityBumpWorkspace(gomock.Any(), database.ActivityBumpWorkspaceParams{
137141
WorkspaceID: workspace.ID,
138142
NextAutostart: time.Time{}.UTC(),
139143
}).Return(nil)
140144

141-
// Workspace last used at gets bumped.
142-
dbM.EXPECT().UpdateWorkspaceLastUsedAt(gomock.Any(), database.UpdateWorkspaceLastUsedAtParams{
143-
ID: workspace.ID,
144-
LastUsedAt: now,
145-
}).Return(nil)
146-
147-
// User gets fetched to hit the UpdateAgentMetricsFn.
148-
dbM.EXPECT().GetUserByID(gomock.Any(), user.ID).Return(user, nil)
149-
150145
// Ensure that pubsub notifications are sent.
151146
notifyDescription := make(chan []byte)
152147
ps.Subscribe(codersdk.WorkspaceNotifyChannel(workspace.ID), func(_ context.Context, description []byte) {
@@ -230,12 +225,6 @@ func TestUpdateStates(t *testing.T) {
230225
TemplateName: template.Name,
231226
}, nil)
232227

233-
// Workspace last used at gets bumped.
234-
dbM.EXPECT().UpdateWorkspaceLastUsedAt(gomock.Any(), database.UpdateWorkspaceLastUsedAtParams{
235-
ID: workspace.ID,
236-
LastUsedAt: now,
237-
}).Return(nil)
238-
239228
_, err := api.UpdateStats(context.Background(), req)
240229
require.NoError(t, err)
241230
})

coderd/workspacestats/reporter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac
134134
AgentName: workspaceAgent.Name,
135135
TemplateName: templateName,
136136
}, stats.Metrics)
137-
return nil
138137
}
139138

140139
// if no active connections we do not bump activity

0 commit comments

Comments
 (0)