feat: filter for running workspaces (#4157)

* Refactor workspaces xservice

* Remove layout comment

* Format

* Add comments

* Add running workspaces filter to frontend

* Start on backend - add status to filter

* Update sql and add test - wip

* Attempt to unconvert status for easier querying

* Fix syntax

* Join jobs table, untested

* sql

* Add Status to GetAuthorizedWorkspaces

* Update job tests to have canceled time

* fmt

* add status filter to database fake

Co-authored-by: Colin Adler <colin1adler@gmail.com>
This commit is contained in:
Presley Pizzo
2022-10-11 13:50:41 -04:00
committed by GitHub
parent aefb477e21
commit 62357084ba
15 changed files with 434 additions and 99 deletions

View File

@ -68,6 +68,7 @@ type ProvisionerJob struct {
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CanceledAt *time.Time `json:"canceled_at,omitempty"`
Error string `json:"error,omitempty"`
Status ProvisionerJobStatus `json:"status"`
WorkerID *uuid.UUID `json:"worker_id,omitempty"`

View File

@ -252,6 +252,8 @@ type WorkspaceFilter struct {
Template string `json:"template,omitempty" typescript:"-"`
// Name will return partial matches
Name string `json:"name,omitempty" typescript:"-"`
// Status is a workspace status, which is really the status of the latest build
Status string `json:"status,omitempty" typescript:"-"`
// FilterQuery supports a raw filter query string
FilterQuery string `json:"q,omitempty"`
}
@ -272,6 +274,9 @@ func (f WorkspaceFilter) asRequestOption() RequestOption {
if f.Template != "" {
params = append(params, fmt.Sprintf("template:%q", f.Template))
}
if f.Status != "" {
params = append(params, fmt.Sprintf("status:%q", f.Status))
}
if f.FilterQuery != "" {
// If custom stuff is added, just add it on here.
params = append(params, f.FilterQuery)