@@ -36,7 +36,7 @@ import (
36
36
"github.com/coder/coder/v2/coderd/httpmw"
37
37
"github.com/coder/coder/v2/coderd/prometheusmetrics"
38
38
"github.com/coder/coder/v2/coderd/rbac/policy"
39
- "github.com/coder/coder/v2/coderd/schedule "
39
+ "github.com/coder/coder/v2/coderd/workspaceapps "
40
40
"github.com/coder/coder/v2/codersdk"
41
41
"github.com/coder/coder/v2/codersdk/agentsdk"
42
42
"github.com/coder/coder/v2/codersdk/workspacesdk"
@@ -1167,35 +1167,6 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
1167
1167
slog .F ("payload" , req ),
1168
1168
)
1169
1169
1170
- if req .ConnectionCount > 0 {
1171
- var nextAutostart time.Time
1172
- if workspace .AutostartSchedule .String != "" {
1173
- templateSchedule , err := (* (api .TemplateScheduleStore .Load ())).Get (ctx , api .Database , workspace .TemplateID )
1174
- // If the template schedule fails to load, just default to bumping without the next transition and log it.
1175
- if err != nil {
1176
- // There's nothing we can do if the query was canceled, the
1177
- // client most likely went away so we just return an internal
1178
- // server error.
1179
- if database .IsQueryCanceledError (err ) {
1180
- httpapi .InternalServerError (rw , err )
1181
- return
1182
- }
1183
- api .Logger .Error (ctx , "failed to load template schedule bumping activity, defaulting to bumping by 60min" ,
1184
- slog .F ("workspace_id" , workspace .ID ),
1185
- slog .F ("template_id" , workspace .TemplateID ),
1186
- slog .Error (err ),
1187
- )
1188
- } else {
1189
- next , allowed := schedule .NextAutostart (time .Now (), workspace .AutostartSchedule .String , templateSchedule )
1190
- if allowed {
1191
- nextAutostart = next
1192
- }
1193
- }
1194
- }
1195
- agentapi .ActivityBumpWorkspace (ctx , api .Logger .Named ("activity_bump" ), api .Database , workspace .ID , nextAutostart )
1196
- }
1197
-
1198
- now := dbtime .Now ()
1199
1170
protoStats := & agentproto.Stats {
1200
1171
ConnectionsByProto : req .ConnectionsByProto ,
1201
1172
ConnectionCount : req .ConnectionCount ,
@@ -1242,19 +1213,6 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
1242
1213
}
1243
1214
return nil
1244
1215
})
1245
- if req .SessionCount () > 0 {
1246
- errGroup .Go (func () error {
1247
- // nolint:gocritic // (#13146) Will be moved soon as part of refactor.
1248
- err := api .Database .UpdateWorkspaceLastUsedAt (ctx , database.UpdateWorkspaceLastUsedAtParams {
1249
- ID : workspace .ID ,
1250
- LastUsedAt : now ,
1251
- })
1252
- if err != nil {
1253
- return xerrors .Errorf ("can't update workspace LastUsedAt: %w" , err )
1254
- }
1255
- return nil
1256
- })
1257
- }
1258
1216
if api .Options .UpdateAgentMetrics != nil {
1259
1217
errGroup .Go (func () error {
1260
1218
user , err := api .Database .GetUserByID (ctx , workspace .OwnerID )
@@ -1277,6 +1235,11 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
1277
1235
return
1278
1236
}
1279
1237
1238
+ api .statsCollector .CollectAndFlush (ctx , workspaceapps.StatsReport {
1239
+ WorkspaceID : workspace .ID ,
1240
+ // TODO: fill out
1241
+ })
1242
+
1280
1243
httpapi .Write (ctx , rw , http .StatusOK , agentsdk.StatsResponse {
1281
1244
ReportInterval : api .AgentStatsRefreshInterval ,
1282
1245
})
0 commit comments