@@ -21,6 +21,7 @@ import (
21
21
"github.com/coder/coder/v2/coderd/rbac"
22
22
"github.com/coder/coder/v2/coderd/rbac/policy"
23
23
"github.com/coder/coder/v2/coderd/schedule"
24
+ "github.com/coder/coder/v2/coderd/searchquery"
24
25
"github.com/coder/coder/v2/coderd/telemetry"
25
26
"github.com/coder/coder/v2/coderd/util/ptr"
26
27
"github.com/coder/coder/v2/coderd/workspacestats"
@@ -457,20 +458,12 @@ func (api *API) fetchTemplates(mutate func(r *http.Request, arg *database.GetTem
457
458
return func (rw http.ResponseWriter , r * http.Request ) {
458
459
ctx := r .Context ()
459
460
460
- p := httpapi .NewQueryParamParser ()
461
- values := r .URL .Query ()
462
-
463
- deprecated := sql.NullBool {}
464
- if values .Has ("deprecated" ) {
465
- deprecated = sql.NullBool {
466
- Bool : p .Boolean (values , false , "deprecated" ),
467
- Valid : true ,
468
- }
469
- }
470
- if len (p .Errors ) > 0 {
461
+ queryStr := r .URL .Query ().Get ("q" )
462
+ filter , errs := searchquery .Templates (ctx , api .Database , queryStr )
463
+ if len (errs ) > 0 {
471
464
httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
472
- Message : "Invalid query params ." ,
473
- Validations : p . Errors ,
465
+ Message : "Invalid template search query ." ,
466
+ Validations : errs ,
474
467
})
475
468
return
476
469
}
@@ -484,9 +477,7 @@ func (api *API) fetchTemplates(mutate func(r *http.Request, arg *database.GetTem
484
477
return
485
478
}
486
479
487
- args := database.GetTemplatesWithFilterParams {
488
- Deprecated : deprecated ,
489
- }
480
+ args := filter
490
481
if mutate != nil {
491
482
mutate (r , & args )
492
483
}
0 commit comments