mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: order workspaces by running first (#7656)
* wip * use updated sql * wip * Implement sorting in databasefake.go * More fixes * sql fmt --------- Co-authored-by: Marcin Tojek <marcin@coder.com>
This commit is contained in:
@ -8172,7 +8172,11 @@ const getWorkspaces = `-- name: GetWorkspaces :many
|
||||
SELECT
|
||||
workspaces.id, workspaces.created_at, workspaces.updated_at, workspaces.owner_id, workspaces.organization_id, workspaces.template_id, workspaces.deleted, workspaces.name, workspaces.autostart_schedule, workspaces.ttl, workspaces.last_used_at, COUNT(*) OVER () as count
|
||||
FROM
|
||||
workspaces
|
||||
workspaces
|
||||
JOIN
|
||||
users
|
||||
ON
|
||||
workspaces.owner_id = users.id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT
|
||||
workspace_builds.transition,
|
||||
@ -8333,7 +8337,12 @@ WHERE
|
||||
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
|
||||
-- @authorize_filter
|
||||
ORDER BY
|
||||
last_used_at DESC
|
||||
(latest_build.completed_at IS NOT NULL AND
|
||||
latest_build.canceled_at IS NULL AND
|
||||
latest_build.error IS NULL AND
|
||||
latest_build.transition = 'start'::workspace_transition) DESC,
|
||||
LOWER(users.username) ASC,
|
||||
LOWER(name) ASC
|
||||
LIMIT
|
||||
CASE
|
||||
WHEN $11 :: integer > 0 THEN
|
||||
|
Reference in New Issue
Block a user