chore: refactor workspace count to single route (#4809)

Co-authored-by: Presley Pizzo <presley@coder.com>
This commit is contained in:
Garrett Delfosse
2022-11-10 13:25:46 -05:00
committed by GitHub
parent 5fb9c33ecd
commit 766a2ad590
23 changed files with 160 additions and 761 deletions

View File

@ -231,17 +231,17 @@ func getWorkspaceAndAgent(ctx context.Context, cmd *cobra.Command, client *coder
err error
)
if shuffle {
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Owner: codersdk.Me,
})
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
}
if len(workspaces) == 0 {
if len(res.Workspaces) == 0 {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.New("no workspaces to shuffle")
}
workspace, err = cryptorand.Element(workspaces)
workspace, err = cryptorand.Element(res.Workspaces)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
}