Skip to content

Commit 2711ded

Browse files
committed
feat: add org resources query
1 parent cc1c564 commit 2711ded

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

coderd/database/queries/organizations.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ WHERE
6666
user_id = $1
6767
);
6868

69+
-- name: GetOrganizationResourceCountByID :one
70+
SELECT
71+
(SELECT COUNT(*) FROM workspaces WHERE workspaces.organization_id = $1 AND workspaces.deleted = false) AS workspace_count,
72+
(SELECT COUNT(*) FROM groups WHERE groups.organization_id = $1) AS group_count,
73+
(SELECT COUNT(*) FROM templates WHERE templates.organization_id = $1 AND templates.deleted = false) AS template_count,
74+
(SELECT COUNT(*) FROM organization_members WHERE organization_members.organization_id = $1) AS member_count,
75+
(SELECT COUNT(*) FROM provisioner_keys WHERE provisioner_keys.organization_id = $1) AS provisioner_key_count;
76+
6977
-- name: InsertOrganization :one
7078
INSERT INTO
7179
organizations (id, "name", display_name, description, icon, created_at, updated_at, is_default)

0 commit comments

Comments
 (0)