mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(cli): port-forward: update workspace last_used_at (#12659)
This PR updates the coder port-forward command to periodically inform coderd that the workspace is being used: - Adds workspaceusage.Tracker which periodically batch-updates workspace LastUsedAt - Adds coderd endpoint to signal workspace usage - Updates coder port-forward to periodically hit this endpoint - Modifies BatchUpdateWorkspacesLastUsedAt to avoid overwriting with stale data Co-authored-by: Danny Kopping <danny@coder.com>
This commit is contained in:
co-authored by
Danny Kopping
parent
d789a60d47
commit
92aa1eba97
@@ -1046,6 +1046,10 @@ func (q *FakeQuerier) BatchUpdateWorkspaceLastUsedAt(_ context.Context, arg data
|
||||
if _, found := m[q.workspaces[i].ID]; !found {
|
||||
continue
|
||||
}
|
||||
// WHERE last_used_at < @last_used_at
|
||||
if !q.workspaces[i].LastUsedAt.Before(arg.LastUsedAt) {
|
||||
continue
|
||||
}
|
||||
q.workspaces[i].LastUsedAt = arg.LastUsedAt
|
||||
n++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user