mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add author filter command to template filtering (#19202)
Can do `author:username` to filter templates created by a certain author. Adding to help clean out some templates that I created on our dev instance. This makes sorting a bit easier.
This commit is contained in:
@@ -59,6 +59,19 @@ WHERE
|
||||
tv.has_ai_task = sqlc.narg('has_ai_task') :: boolean
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by author_id
|
||||
AND CASE
|
||||
WHEN @author_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN
|
||||
t.created_by = @author_id
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by author_username
|
||||
AND CASE
|
||||
WHEN @author_username :: text != '' THEN
|
||||
t.created_by = (SELECT id FROM users WHERE lower(users.username) = lower(@author_username) AND deleted = false)
|
||||
ELSE true
|
||||
END
|
||||
|
||||
-- Authorize Filter clause will be injected below in GetAuthorizedTemplates
|
||||
-- @authorize_filter
|
||||
ORDER BY (t.name, t.id) ASC
|
||||
|
||||
Reference in New Issue
Block a user