Skip to content

Commit df2acd3

Browse files
committed
chore: include organization name when fetching templates
1 parent 5bf46f3 commit df2acd3

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

coderd/database/dump.sql

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE VIEW
2+
template_with_users
3+
AS
4+
SELECT
5+
templates.*,
6+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
7+
coalesce(visible_users.username, '') AS created_by_username
8+
FROM
9+
templates
10+
LEFT JOIN
11+
visible_users
12+
ON
13+
templates.created_by = visible_users.id;
14+
COMMENT ON VIEW template_with_users IS 'Joins in the username + avatar url of the created by user.';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Update the template_with_users view by recreating it.
2+
DROP VIEW template_with_users;
3+
4+
CREATE VIEW
5+
template_with_users
6+
AS
7+
SELECT
8+
templates.*,
9+
coalesce(visible_users.avatar_url, '') AS created_by_avatar_url,
10+
coalesce(visible_users.username, '') AS created_by_username,
11+
coalesce(organizations.name, '') AS organization_name
12+
FROM
13+
templates
14+
LEFT JOIN
15+
visible_users
16+
ON
17+
templates.created_by = visible_users.id
18+
LEFT JOIN
19+
organizations
20+
ON templates.organization_id = organizations.id
21+
;
22+
23+
COMMENT ON VIEW template_with_users IS 'Joins in the display name information such as username, avatar, and organization name.';

coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func (q *sqlQuerier) GetAuthorizedTemplates(ctx context.Context, arg GetTemplate
116116
&i.MaxPortSharingLevel,
117117
&i.CreatedByAvatarURL,
118118
&i.CreatedByUsername,
119+
&i.OrganizationName,
119120
); err != nil {
120121
return nil, err
121122
}

coderd/database/models.go

Lines changed: 2 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: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)