feat: add has-ai-task filters to the /workspaces and /templates endpoints (#18387)

This PR allows filtering templates and workspaces with the `has-ai-task`
filter as described in the [Coder Tasks
RFC](https://www.notion.so/coderhq/Coder-Tasks-207d579be5928053ab68c8d9a4b59eaa?source=copy_link#20ad579be59280e6a000eb0646d3c2df).
This commit is contained in:
Hugo Dutka
2025-06-18 18:22:45 +02:00
committed by GitHub
parent 56ff0fb65a
commit 591f5db5f6
16 changed files with 431 additions and 51 deletions

View File

@ -222,6 +222,36 @@ func TestSearchWorkspace(t *testing.T) {
OrganizationID: uuid.MustParse("08eb6715-02f8-45c5-b86d-03786fcfbb4e"),
},
},
{
Name: "HasAITaskTrue",
Query: "has-ai-task:true",
Expected: database.GetWorkspacesParams{
HasAITask: sql.NullBool{
Bool: true,
Valid: true,
},
},
},
{
Name: "HasAITaskFalse",
Query: "has-ai-task:false",
Expected: database.GetWorkspacesParams{
HasAITask: sql.NullBool{
Bool: false,
Valid: true,
},
},
},
{
Name: "HasAITaskMissing",
Query: "",
Expected: database.GetWorkspacesParams{
HasAITask: sql.NullBool{
Bool: false,
Valid: false,
},
},
},
// Failures
{
@ -559,6 +589,36 @@ func TestSearchTemplates(t *testing.T) {
FuzzyName: "foobar",
},
},
{
Name: "HasAITaskTrue",
Query: "has-ai-task:true",
Expected: database.GetTemplatesWithFilterParams{
HasAITask: sql.NullBool{
Bool: true,
Valid: true,
},
},
},
{
Name: "HasAITaskFalse",
Query: "has-ai-task:false",
Expected: database.GetTemplatesWithFilterParams{
HasAITask: sql.NullBool{
Bool: false,
Valid: true,
},
},
},
{
Name: "HasAITaskMissing",
Query: "",
Expected: database.GetTemplatesWithFilterParams{
HasAITask: sql.NullBool{
Bool: false,
Valid: false,
},
},
},
}
for _, c := range testCases {