mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
fix(coderd): workspaceapps: update last_used_at when workspace app reports stats (#11603)
- Adds a new query BatchUpdateLastUsedAt - Adds calls to BatchUpdateLastUsedAt in app stats handler upon flush - Passes a stats flush channel to apptest setup scaffolding and updates unit tests to assert modifications to LastUsedAt.
This commit is contained in:
@ -37,6 +37,9 @@ type ProxyOptions struct {
|
||||
|
||||
// ProxyURL is optional
|
||||
ProxyURL *url.URL
|
||||
|
||||
// FlushStats is optional
|
||||
FlushStats chan chan<- struct{}
|
||||
}
|
||||
|
||||
// NewWorkspaceProxy will configure a wsproxy.Server with the given options.
|
||||
@ -113,6 +116,9 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
|
||||
// Inherit collector options from coderd, but keep the wsproxy reporter.
|
||||
statsCollectorOptions := coderdAPI.Options.WorkspaceAppsStatsCollectorOptions
|
||||
statsCollectorOptions.Reporter = nil
|
||||
if options.FlushStats != nil {
|
||||
statsCollectorOptions.Flush = options.FlushStats
|
||||
}
|
||||
|
||||
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
|
||||
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),
|
||||
|
Reference in New Issue
Block a user