8000 fix: user user.name as owner_name instead of user.username · coder/coder@4ad041d · GitHub
[go: up one dir, main page]

Skip to content

Co 10000 mmit 4ad041d

Browse files
committed
fix: user user.name as owner_name instead of user.username
1 parent 70edc24 commit 4ad041d

17 files changed

+515
-27
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"workspace_name": "test-workspace",
2525
"workspace_owner_id": "==========[first user ID]===========",
2626
"workspace_owner_name": "testuser",
27+
"workspace_owner_username": "testuser",
2728
"template_version_id": "============[version ID]============",
2829
"template_version_name": "===========[version name]===========",
2930
"build_number": 1,

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/database/dump.sql

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
-- Recreate `template_version_with_user` as described in dump.sql
2+
DROP VIEW template_version_with_user;
3+
4+
CREATE VIEW template_version_with_user AS
5+
SELECT
6+
template_versions.id,
7+
template_versions.template_id,
8+
template_versions.organization_id,
9+
template_versions.created_at,
10+
template_versions.updated_at,
11+
template_versions.name,
12+
template_versions.readme,
13+
template_versions.job_id,
14+
template_versions.created_by,
15+
template_versions.external_auth_providers,
16+
template_versions.message,
17+
template_versions.archived,
18+
template_versions.source_example_id,
19+
COALESCE(
20+
visible_users.avatar_url,
21+
''::text
22+
) AS created_by_avatar_url,
23+
COALESCE(
24+
visible_users.username,
25+
''::text
26+
) AS created_by_username
27+
FROM (
28+
template_versions
29+
LEFT JOIN visible_users ON (
30+
template_versions.created_by = visible_users.id
31+
)
32+
);
33+
34+
COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';
35+
36+
-- Recreate `visible_users` as described in dump.sql
37+
DROP VIEW visible_users;
38+
39+
CREATE VIEW visible_users AS
40+
SELECT users.id, users.username, users.avatar_url
41+
FROM users;
42+
43+
COMMENT ON VIEW visible_users IS 'Visible fields of users are allowed to be joined with other tables for including context of other resources.';
44+
45+
-- Recreate `workspace_build_with_user` as described in dump.sql
46+
DROP VIEW workspace_build_with_user;
47+
48+
CREATE VIEW workspace_build_with_user AS
49+
SELECT
50+
workspace_builds.id,
51+
workspace_builds.created_at,
52+
workspace_builds.updated_at,
53+
workspace_builds.workspace_id,
54+
workspace_builds.template_version_id,
55+
workspace_builds.build_number,
56+
workspace_builds.transition,
57+
workspace_builds.initiator_id,
58+
workspace_builds.provisioner_state,
59+
workspace_builds.job_id,
60+
workspace_builds.deadline,
61+
workspace_builds.reason,
62+
workspace_builds.daily_cost,
63+
workspace_builds.max_deadline,
64+
workspace_builds.template_version_preset_id,
65+
COALESCE(
66+
visible_users.avatar_url,
67+
''::text
68+
) AS initiator_by_avatar_url,
69+
COALESCE(
70+
visible_users.username,
71+
''::text
72+
) AS initiator_by_username
73+
FROM (
74+
workspace_builds
75+
LEFT JOIN visible_users ON (
76+
(
77+
workspace_builds.initiator_id = visible_users.id
78+
)
79+
)
80+
);
81+
82+
COMMENT ON VIEW workspace_build_with_user IS 'Joins in the username + avatar url of the initiated by user.';
83+
84+
-- Recreate `workspaces_expanded` as described in dump.sql
85+
DROP VIEW workspaces_expanded;
86+
87+
CREATE VIEW workspaces_expanded AS
88+
SELECT
89+
workspaces.id,
90+
workspaces.created_at,
91+
workspaces.updated_at,
92+
workspaces.owner_id,
93+
workspaces.organization_id,
94+
workspaces.template_id,
95+
workspaces.deleted,
96+
workspaces.name,
97+
workspaces.autostart_schedule,
98+
workspaces.ttl,
99+
workspaces.last_used_at,
100+
workspaces.dormant_at,
101+
workspaces.deleting_at,
102+
workspaces.automatic_updates,
103+
workspaces.favorite,
104+
workspaces.next_start_at,
105+
visible_users.avatar_url AS owner_avatar_url,
106+
visible_users.username AS owner_username,
107+
organizations.name AS organization_name,
108+
organizations.display_name AS organization_display_name,
109+
organizations.icon AS organization_icon,
110+
organizations.description AS organization_description,
111+
templates.name AS template_name,
112+
templates.display_name AS template_display_name,
113+
templates.icon AS template_icon,
114+
templates.description AS template_description
115+
FROM (
116+
(
117+
(
118+
workspaces
119+
JOIN visible_users ON (
120+
(
121+
workspaces.owner_id = visible_users.id
122+
)
123+
)
124+
)
125+
JOIN organizations ON (
126+
(
127+
workspaces.organization_id = organizations.id
128+
)
129+
)
130+
)
131+
JOIN templates ON (
132+
(
133+
workspaces.template_id = templates.id
134+
)
135+
)
136+
);
137+
138+
COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.';
139+
140+
-- Recreate `template_with_names` as described in dump.sql
141+
DROP VIEW template_with_names;
142+
143+
CREATE VIEW template_with_names AS
144+
SELECT
145+
templates.id,
146+
templates.created_at,
147+
templates.updated_at,
148+
templates.organization_id,
149+
templates.deleted,
150+
templates.name,
151+
templates.provisioner,
152+
templates.active_version_id,
153+
templates.description,
154+
templates.default_ttl,
155+
templates.created_by,
156+
templates.icon,
157+
templates.user_acl,
158+
templates.group_acl,
159+
templates.display_name,
160+
templates.allow_user_cancel_workspace_jobs,
161+
templates.allow_user_autostart,
162+
templates.allow_user_autostop,
163+
templates.failure_ttl,
164+
templates.time_til_dormant,
165+
templates.time_til_dormant_autodelete,
166+
templates.autostop_requirement_days_of_week,
167+
templates.autostop_requirement_weeks,
168+
templates.autostart_block_days_of_week,
169+
templates.require_active_version,
170+
templates.deprecated,
171+
templates.activity_bump,
172+
templates.max_port_sharing_level,
173+
templates.use_classic_parameter_flow,
174+
COALESCE(
175+
visible_users.avatar_url,
176+
''::text
177+
) AS created_by_avatar_url,
178+
COALESCE(
179+
visible_users.username,
180+
''::text
181+
) AS created_by_username,
182+
COALESCE(organizations.name, ''::text) AS organization_name,
183+
COALESCE(
184+
organizations.display_name,
185+
''::text
186+
) AS organization_display_name,
187+
COALESCE(organizations.icon, ''::text) AS organization_icon
188+
FROM (
189+
(
190+
templates
191+
LEFT JOIN visible_users ON (
192+
(
193+
templates.created_by = visible_users.id
194+
)
195+
)
196+
)
197+
LEFT JOIN organizations ON (
198+
(
199+
templates.organization_id = organizations.id
200+
)
201+
)
202+
);
203+
204+
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
205+
206+
-- Recreate `template_version_with_user` as described in dump.sql
207+
DROP VIEW template_version_with_user;
208+
209+
CREATE VIEW template_version_with_user AS
210+
SELECT
211+
template_versions.id,
212+
template_versions.template_id,
213+
template_versions.organization_id,
214+
template_versions.created_at,
215+
template_versions.updated_at,
216+
template_versions.name,
217+
template_versions.readme,
218+
template_versions.job_id,
219+
template_versions.created_by,
220+
template_versions.external_auth_providers,
221+
template_versions.message,
222+
template_versions.archived,
223+
template_versions.source_example_id,
224+
COALESCE(
225+
visible_users.avatar_url,
226+
''::text
227+
) AS created_by_avatar_url,
228+
COALESCE(
229+
visible_users.username,
230+
''::text
231+
) AS created_by_username
232+
FROM (
233+
template_versions
234+
LEFT JOIN visible_users ON (
235+
(
236+
template_versions.created_by = visible_users.id
237+
)
238+
)
239+
);
240+
241+
COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';

0 commit comments

Comments
 (0)
0