mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add "updated" search param to workspaces (#11714)
* feat: add "updated" search param to workspaces * rego -> sql needs to specify which <table>.organization_id
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package searchquery
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -110,6 +111,14 @@ func Workspaces(query string, page codersdk.Pagination, agentInactiveDisconnectT
|
||||
filter.Dormant = parser.Boolean(values, false, "dormant")
|
||||
filter.LastUsedAfter = parser.Time3339Nano(values, time.Time{}, "last_used_after")
|
||||
filter.LastUsedBefore = parser.Time3339Nano(values, time.Time{}, "last_used_before")
|
||||
filter.UsingActive = sql.NullBool{
|
||||
// Invert the value of the query parameter to get the correct value.
|
||||
// UsingActive returns if the workspace is on the latest template active version.
|
||||
Bool: !parser.Boolean(values, true, "outdated"),
|
||||
// Only include this search term if it was provided. Otherwise default to omitting it
|
||||
// which will return all workspaces.
|
||||
Valid: values.Has("outdated"),
|
||||
}
|
||||
|
||||
parser.ErrorExcessParams(values)
|
||||
return filter, parser.Errors
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package searchquery_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -116,7 +117,26 @@ func TestSearchWorkspace(t *testing.T) {
|
||||
OwnerUsername: "foo",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Name: "Outdated",
|
||||
Query: `outdated:true`,
|
||||
Expected: database.GetWorkspacesParams{
|
||||
UsingActive: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Updated",
|
||||
Query: `outdated:false`,
|
||||
Expected: database.GetWorkspacesParams{
|
||||
UsingActive: sql.NullBool{
|
||||
Bool: true,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
// Failures
|
||||
{
|
||||
Name: "NoPrefix",
|
||||
|
||||
Reference in New Issue
Block a user