8000 Filter query: has-agent connecting, connected, disconnected, timeout by mtojek · Pull Request #5145 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

Filter query: has-agent connecting, connected, disconnected, timeout #5145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Nov 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: typo
  • Loading branch information
mtojek committed Nov 22, 2022
commit f9e2167976d0fcc6c840a83948cf4673f0a135e0
12 changes: 6 additions & 6 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,23 +897,23 @@ func (q *fakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
return nil, xerrors.Errorf("get workspace agents: %w", err)
}

var hasAgentValid bool
var hasAgentMatched bool
for _, wa := range workspaceAgents {
switch arg.HasAgent {
case "connected":
hasAgentValid = wa.LastConnectedAt.Valid
hasAgentMatched = wa.LastConnectedAt.Valid
case "connecting":
hasAgentValid = !wa.FirstConnectedAt.Valid
hasAgentMatched = !wa.FirstConnectedAt.Valid
case "disconnected":
hasAgentValid = wa.DisconnectedAt.Valid && wa.DisconnectedAt.Time.After(wa.LastConnectedAt.Time)
hasAgentMatched = wa.DisconnectedAt.Valid && wa.DisconnectedAt.Time.After(wa.LastConnectedAt.Time)
case "timeout":
hasAgentValid = !wa.FirstConnectedAt.Valid &&
hasAgentMatched = !wa.FirstConnectedAt.Valid &&
wa.CreatedAt.Add(time.Duration(wa.ConnectionTimeoutSeconds)*time.Second).Before(database.Now())
}
break // only 1 agent is expected
}

if !hasAgentValid {
if !hasAgentMatched {
continue
}
}
Expand Down
0