Skip to content

Commit b5f5705

Browse files
committed
Remove unused code/params
1 parent 9368c48 commit b5f5705

File tree

8 files changed

+24
-144
lines changed

8 files changed

+24
-144
lines changed

coderd/database/databasefake/databasefake.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ func (q *fakeQuerier) GetWorkspacesWithFilter(_ context.Context, arg database.Ge
321321

322322
workspaces := make([]database.Workspace, 0)
323323
for _, workspace := range q.workspaces {
324-
if arg.OrganizationID != uuid.Nil && workspace.OrganizationID != arg.OrganizationID {
325-
continue
326-
}
327324
if arg.OwnerID != uuid.Nil && workspace.OwnerID != arg.OwnerID {
328325
continue
329326
}
@@ -634,25 +631,6 @@ func (q *fakeQuerier) GetWorkspaceBuildByWorkspaceIDAndName(_ context.Context, a
634631
return database.WorkspaceBuild{}, sql.ErrNoRows
635632
}
636633

637-
func (q *fakeQuerier) GetWorkspacesByOrganizationIDs(_ context.Context, req database.GetWorkspacesByOrganizationIDsParams) ([]database.Workspace, error) {
638-
q.mutex.RLock()
639-
defer q.mutex.RUnlock()
640-
641-
workspaces := make([]database.Workspace, 0)
642-
for _, workspace := range q.workspaces {
643-
for _, id := range req.Ids {
644-
if workspace.OrganizationID != id {
645-
continue
646-
}
647-
if workspace.Deleted != req.Deleted {
648-
continue
649-
}
650-
workspaces = append(workspaces, workspace)
651-
}
652-
}
653-
return workspaces, nil
654-
}
655-
656634
func (q *fakeQuerier) GetOrganizations(_ context.Context) ([]database.Organization, error) {
657635
q.mutex.RLock()
658636
defer q.mutex.RUnlock()

coderd/database/querier.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 16 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaces.sql

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ FROM
1616
WHERE
1717
-- Optionally include deleted workspaces
1818
workspaces.deleted = @deleted
19-
-- Filter by organization_id
20-
AND CASE
21-
WHEN @organization_id :: uuid != '00000000-00000000-00000000-00000000' THEN
22-
organization_id = @organization_id
23-
ELSE true
24-
END
2519
-- Filter by owner_id
2620
AND CASE
2721
WHEN @owner_id :: uuid != '00000000-00000000-00000000-00000000' THEN
@@ -56,9 +50,6 @@ WHERE
5650
END
5751
;
5852

59-
-- name: GetWorkspacesByOrganizationIDs :many
60-
SELECT * FROM workspaces WHERE organization_id = ANY(@ids :: uuid [ ]) AND deleted = @deleted;
61-
6253
-- name: GetWorkspacesAutostart :many
6354
SELECT
6455
*

coderd/workspaces.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,10 @@ func (api *API) workspaces(rw http.ResponseWriter, r *http.Request) {
132132

133133
parser := httpapi.NewQueryParamParser()
134134
filter := database.GetWorkspacesWithFilterParams{
135-
Deleted: false,
136-
OrganizationID: parser.ParseUUID(r, uuid.Nil, "organization_id"),
137-
OwnerUsername: parser.ParseString(r, "", "owner"),
138-
TemplateName: parser.ParseString(r, "", "template"),
139-
TemplateIds: parser.ParseUUIDArray(r, []uuid.UUID{}, "template_ids"),
140-
Name: parser.ParseString(r, "", "name"),
135+
Deleted: false,
136+
OwnerUsername: parser.ParseString(r, "", "owner"),
137+
TemplateName: parser.ParseString(r, "", "template"),
138+
Name: parser.ParseString(r, "", "name"),
141139
}
142140
if len(parser.ValidationErrors()) > 0 {
143141
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{

coderd/workspaces_test.go

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,6 @@ func TestWorkspaceFilter(t *testing.T) {
432432
return workspace.Owner.Username == f.Owner
433433
},
434434
},
435-
{
436-
Name: "OrgID",
437-
Filter: codersdk.WorkspaceFilter{
438-
OrganizationID: users[must(cryptorand.Intn(len(users)))].Org.ID,
439-
},
440-
FilterF: func(f codersdk.WorkspaceFilter, workspace madeWorkspace) bool {
441-
return workspace.Template.OrganizationID == f.OrganizationID
442-
},
443-
},
444435
{
445436
Name: "TemplateName",
446437
Filter: codersdk.WorkspaceFilter{
@@ -457,7 +448,7 @@ func TestWorkspaceFilter(t *testing.T) {
457448
Name: "a",
458449
},
459450
FilterF: func(f codersdk.WorkspaceFilter, workspace madeWorkspace) bool {
460-
return strings.Contains(workspace.Workspace.Name, f.Name)
451+
return workspace.Template.Name == f.Template && strings.Contains(workspace.Workspace.Name, f.Name)
461452
},
462453
},
463454
{
@@ -469,33 +460,12 @@ func TestWorkspaceFilter(t *testing.T) {
469460
return workspace.Workspace.ID == allWorkspaces[5].Workspace.ID
470461
},
471462
},
472-
{
473-
Name: "Org&Owner",
474-
Filter: codersdk.WorkspaceFilter{
475-
OrganizationID: users[2].Org.ID,
476-
Owner: users[2].User.Username,
477-
},
478-
FilterF: func(f codersdk.WorkspaceFilter, workspace madeWorkspace) bool {
479-
return workspace.Owner.Username == f.Owner && workspace.Template.OrganizationID == f.OrganizationID
480-
},
481-
},
482-
{
483-
Name: "Org&Owner",
484-
Filter: codersdk.WorkspaceFilter{
485-
OrganizationID: users[2].Org.ID,
486-
Owner: users[2].User.Username,
487-
},
488-
FilterF: func(f codersdk.WorkspaceFilter, workspace madeWorkspace) bool {
489-
return workspace.Owner.Username == f.Owner && workspace.Template.OrganizationID == f.OrganizationID
490-
},
491-
},
492463
{
493464
Name: "Many filters",
494465
Filter: codersdk.WorkspaceFilter{
495-
OrganizationID: allWorkspaces[3].Template.OrganizationID,
496-
Owner: allWorkspaces[3].Owner.Username,
497-
Template: allWorkspaces[3].Template.Name,
498-
Name: allWorkspaces[3].Workspace.Name,
466+
Owner: allWorkspaces[3].Owner.Username,
467+
Template: allWorkspaces[3].Template.Name,
468+
Name: allWorkspaces[3].Workspace.Name,
499469
},
500470
FilterF: func(f codersdk.WorkspaceFilter, workspace madeWorkspace) bool {
501471
return workspace.Workspace.ID == allWorkspaces[3].Workspace.ID

codersdk/workspaces.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func (c *Client) PutExtendWorkspace(ctx context.Context, id uuid.UUID, req PutEx
217217
}
218218

219219
type WorkspaceFilter struct {
220-
OrganizationID uuid.UUID `json:"organization_id,omitempty"`
221220
// Owner can be "me" or a username
222221
Owner string `json:"owner,omitempty"`
223222
// Template is a template name
@@ -233,9 +232,6 @@ type WorkspaceFilter struct {
233232
func (f WorkspaceFilter) asRequestOption() requestOption {
234233
return func(r *http.Request) {
235234
q := r.URL.Query()
236-
if f.OrganizationID != uuid.Nil {
237-
q.Set("organization_id", f.OrganizationID.String())
238-
}
239235
if f.Owner != "" {
240236
q.Set("owner", f.Owner)
241237
}

site/src/api/typesGenerated.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ export interface WorkspaceBuildsRequest extends Pagination {
466466

467467
// From codersdk/workspaces.go:219:6
468468
export interface WorkspaceFilter {
469-
readonly organization_id?: string
470469
readonly owner?: string
471470
readonly template?: string
472471
readonly name?: string

0 commit comments

Comments
 (0)