mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Fix workspace count to exclude deleted workspaces (#2916)
This commit is contained in:
@@ -527,7 +527,7 @@ func (q *fakeQuerier) GetWorkspaceOwnerCountsByTemplateIDs(_ context.Context, te
|
||||
|
||||
counts := map[uuid.UUID]map[uuid.UUID]struct{}{}
|
||||
for _, templateID := range templateIDs {
|
||||
found := false
|
||||
counts[templateID] = map[uuid.UUID]struct{}{}
|
||||
for _, workspace := range q.workspaces {
|
||||
if workspace.TemplateID != templateID {
|
||||
continue
|
||||
@@ -541,11 +541,6 @@ func (q *fakeQuerier) GetWorkspaceOwnerCountsByTemplateIDs(_ context.Context, te
|
||||
}
|
||||
countByOwnerID[workspace.OwnerID] = struct{}{}
|
||||
counts[templateID] = countByOwnerID
|
||||
found = true
|
||||
break
|
||||
}
|
||||
if !found {
|
||||
counts[templateID] = map[uuid.UUID]struct{}{}
|
||||
}
|
||||
}
|
||||
res := make([]database.GetWorkspaceOwnerCountsByTemplateIDsRow, 0)
|
||||
|
||||
@@ -4058,6 +4058,8 @@ FROM
|
||||
workspaces
|
||||
WHERE
|
||||
template_id = ANY($1 :: uuid [ ])
|
||||
-- Ignore deleted workspaces
|
||||
AND deleted != true
|
||||
GROUP BY
|
||||
template_id
|
||||
`
|
||||
|
||||
@@ -83,6 +83,8 @@ FROM
|
||||
workspaces
|
||||
WHERE
|
||||
template_id = ANY(@ids :: uuid [ ])
|
||||
-- Ignore deleted workspaces
|
||||
AND deleted != true
|
||||
GROUP BY
|
||||
template_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user