Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit804f4a1

Browse files
committed
add pinned status to GetWorkspaces/GetAuthorizedWorkspaces queries
1 parentfaeab68 commit804f4a1

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

‎coderd/database/modelqueries.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
213213
// The name comment is for metric tracking
214214
query:=fmt.Sprintf("-- name: GetAuthorizedWorkspaces :many\n%s",filtered)
215215
rows,err:=q.db.QueryContext(ctx,query,
216+
arg.OwnerID,
216217
arg.Deleted,
217218
arg.Status,
218-
arg.OwnerID,
219219
arg.OwnerUsername,
220220
arg.TemplateName,
221221
pq.Array(arg.TemplateIDs),
@@ -253,6 +253,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
253253
&i.TemplateName,
254254
&i.TemplateVersionID,
255255
&i.TemplateVersionName,
256+
&i.Pinned,
256257
&i.Count,
257258
);err!=nil {
258259
returnnil,err

‎coderd/database/queries.sql.go

Lines changed: 32 additions & 15 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/workspaces.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ SELECT
8282
COALESCE(template_name.template_name,'unknown')as template_name,
8383
latest_build.template_version_id,
8484
latest_build.template_version_name,
85+
(upw.user_idIS NOT NULL)::booleanAS pinned,
8586
COUNT(*) OVER ()as count
8687
FROM
8788
workspaces
@@ -126,6 +127,19 @@ LEFT JOIN LATERAL (
126127
WHERE
127128
templates.id=workspaces.template_id
128129
) template_nameON true
130+
LEFT JOIN LATERAL (
131+
SELECT
132+
user_id
133+
FROM
134+
user_pinned_workspaces
135+
WHERE
136+
workspaces.id=user_pinned_workspaces.workspace_id
137+
AND
138+
-- Omitting the owner_id parameter will result in
139+
-- 00000000-0000-0000-0000-000000000000 which will not match
140+
-- any rows in user_pinned_workspaces.
141+
user_pinned_workspaces.user_id= @owner_id
142+
) upwON TRUE
129143
WHERE
130144
-- Optionally include deleted workspaces
131145
workspaces.deleted= @deleted
@@ -262,6 +276,7 @@ WHERE
262276
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
263277
-- @authorize_filter
264278
ORDER BY
279+
pinnedDESC,
265280
(latest_build.completed_atIS NOT NULLAND
266281
latest_build.canceled_at ISNULLAND
267282
latest_build.error ISNULLAND

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp