mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add pr, repo, pr_title chat search filters (#25569)
Relates to CODAGT-432 Adds three new search filters to the chat list endpoint (`GET /api/experimental/chats/`): - `pr:<number>` - exact PR number match - `repo:<owner/repo>` - substring match against git remote origin or URL - `pr_title:<text>` - case-insensitive PR title substring match Includes SQL filter clauses (EXISTS against `chat_diff_statuses`), parser with validation, handler wiring, unit tests, swagger annotation update, and a new search syntax documentation page. > 🤖 Generated with [Coder Agents](https://coder.com/agents)
This commit is contained in:
@@ -569,6 +569,39 @@ WHERE
|
||||
)
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by PR number (exact match on chat's diff status).
|
||||
AND CASE
|
||||
WHEN @pr_number::int != 0 THEN EXISTS (
|
||||
SELECT 1
|
||||
FROM chat_diff_statuses cds
|
||||
WHERE cds.chat_id = chats_expanded.id
|
||||
AND cds.pr_number = @pr_number
|
||||
)
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by repository (substring match on remote origin or PR URL).
|
||||
AND CASE
|
||||
WHEN @repo_query::text != '' THEN EXISTS (
|
||||
SELECT 1
|
||||
FROM chat_diff_statuses cds
|
||||
WHERE cds.chat_id = chats_expanded.id
|
||||
AND (
|
||||
cds.git_remote_origin ILIKE '%' || @repo_query || '%'
|
||||
OR cds.url ILIKE '%' || @repo_query || '%'
|
||||
)
|
||||
)
|
||||
ELSE true
|
||||
END
|
||||
-- Filter by pull request title (case-insensitive substring).
|
||||
AND CASE
|
||||
WHEN @pr_title_query::text != '' THEN EXISTS (
|
||||
SELECT 1
|
||||
FROM chat_diff_statuses cds
|
||||
WHERE cds.chat_id = chats_expanded.id
|
||||
AND cds.pull_request_title ILIKE '%' || @pr_title_query || '%'
|
||||
)
|
||||
ELSE true
|
||||
END
|
||||
-- Paginate over root chats only. Children are fetched
|
||||
-- separately via GetChildChatsByParentIDs and embedded under
|
||||
-- each parent. Other callers that need the full set should
|
||||
|
||||
Reference in New Issue
Block a user