mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: implement fuzzy name matching for templates (#14211)
* chore: add fuzzy name search for templates * chore: implement fuzzy name matching for templates Templates search query defaults to a fuzzy name match
This commit is contained in:
@@ -198,6 +198,7 @@ func Templates(ctx context.Context, db database.Store, query string) (database.G
|
||||
|
||||
parser := httpapi.NewQueryParamParser()
|
||||
filter := database.GetTemplatesWithFilterParams{
|
||||
FuzzyName: parser.String(values, "", "name"),
|
||||
Deleted: parser.Boolean(values, false, "deleted"),
|
||||
ExactName: parser.String(values, "", "exact_name"),
|
||||
IDs: parser.UUIDs(values, []uuid.UUID{}, "ids"),
|
||||
|
||||
@@ -469,6 +469,13 @@ func TestSearchTemplates(t *testing.T) {
|
||||
Query: "",
|
||||
Expected: database.GetTemplatesWithFilterParams{},
|
||||
},
|
||||
{
|
||||
Name: "OnlyName",
|
||||
Query: "foobar",
|
||||
Expected: database.GetTemplatesWithFilterParams{
|
||||
FuzzyName: "foobar",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user