Skip to content

Commit 1584c38

Browse files
committed
list wf accepts single status for filtering
1 parent 24397b3 commit 1584c38

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

dbos/admin_server.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type listWorkflowsRequest struct {
3737
AuthenticatedUser *string `json:"authenticated_user"` // Filter by user who initiated the workflow
3838
StartTime *time.Time `json:"start_time"` // Filter workflows created after this time (RFC3339 format)
3939
EndTime *time.Time `json:"end_time"` // Filter workflows created before this time (RFC3339 format)
40-
Status []string `json:"status"` // Filter by workflow status(es)
40+
Status string `json:"status"` // Filter by workflow status(es)
4141
ApplicationVersion *string `json:"application_version"` // Filter by application version
4242
WorkflowName *string `json:"workflow_name"` // Filter by workflow function name
4343
Limit *int `json:"limit"` // Maximum number of results to return
@@ -65,10 +65,8 @@ func (req *listWorkflowsRequest) toListWorkflowsOptions() []ListWorkflowsOption
6565
opts = append(opts, WithEndTime(*req.EndTime))
6666
}
6767
if len(req.Status) > 0 {
68-
statuses := make([]WorkflowStatusType, len(req.Status))
69-
for i, s := range req.Status {
70-
statuses[i] = WorkflowStatusType(s)
71-
}
68+
statuses := make([]WorkflowStatusType, 1)
69+
statuses[0] = WorkflowStatusType(req.Status)
7270
opts = append(opts, WithStatus(statuses))
7371
}
7472
if req.ApplicationVersion != nil {

dbos/admin_server_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ func TestAdminServer(t *testing.T) {
161161
},
162162
},
163163
{
164-
name: "Workflows endpoint accepts all filters without error",
165-
method: "POST",
166-
endpoint: fmt.Sprintf("http://localhost:3001/%s", strings.TrimPrefix(_WORKFLOWS_PATTERN, "POST /")),
164+
name: "Workflows endpoint accepts all filters without error",
165+
method: "POST",
166+
endpoint: fmt.Sprintf("http://localhost:3001/%s", strings.TrimPrefix(_WORKFLOWS_PATTERN, "POST /")),
167167
body: bytes.NewBuffer(mustMarshal(map[string]any{
168168
"workflow_uuids": []string{"test-id-1", "test-id-2"},
169169
"authenticated_user": "test-user",
170170
"start_time": time.Now().Add(-24 * time.Hour).Format(time.RFC3339),
171171
"end_time": time.Now().Format(time.RFC3339),
172-
"status": []string{"PENDING", "SUCCESS"},
172+
"status": "PENDING",
173173
"application_version": "v1.0.0",
174174
"workflow_name": "testWorkflow",
175175
"limit": 100,

0 commit comments

Comments
 (0)