Skip to content

Commit 61eee56

Browse files
chore: remove boolean parameter with with WithSortDesc function
1 parent f3c10f3 commit 61eee56

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

dbos/admin_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (req *listWorkflowsRequest) toListWorkflowsOptions() []ListWorkflowsOption
8181
opts = append(opts, WithOffset(*req.Offset))
8282
}
8383
if req.SortDesc != nil {
84-
opts = append(opts, WithSortDesc(*req.SortDesc))
84+
opts = append(opts, WithSortDesc())
8585
}
8686
if req.WorkflowIDPrefix != nil {
8787
opts = append(opts, WithWorkflowIDPrefix(*req.WorkflowIDPrefix))

dbos/client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,13 @@ func TestListWorkflows(t *testing.T) {
805805

806806
// Test 7: Test sorting order (ascending - default)
807807
ascWorkflows, err := ListWorkflows(clientCtx,
808-
WithWorkflowIDPrefix("test-"),
809-
WithSortDesc(false))
808+
WithWorkflowIDPrefix("test-"))
810809
require.NoError(t, err, "failed to list workflows ascending")
811810

812811
// Test 8: Test sorting order (descending)
813812
descWorkflows, err := ListWorkflows(clientCtx,
814813
WithWorkflowIDPrefix("test-"),
815-
WithSortDesc(true))
814+
WithSortDesc())
816815
require.NoError(t, err, "failed to list workflows descending")
817816

818817
// Verify sorting - workflows should be ordered by creation time

dbos/conductor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func (c *Conductor) handleListWorkflowsRequest(data []byte, requestID string) er
562562
var opts []ListWorkflowsOption
563563
opts = append(opts, WithLoadInput(req.Body.LoadInput))
564564
opts = append(opts, WithLoadOutput(req.Body.LoadOutput))
565-
opts = append(opts, WithSortDesc(req.Body.SortDesc))
565+
opts = append(opts, WithSortDesc())
566566
if len(req.Body.WorkflowUUIDs) > 0 {
567567
opts = append(opts, WithWorkflowIDs(req.Body.WorkflowUUIDs))
568568
}
@@ -638,7 +638,7 @@ func (c *Conductor) handleListQueuedWorkflowsRequest(data []byte, requestID stri
638638
var opts []ListWorkflowsOption
639639
opts = append(opts, WithLoadInput(req.Body.LoadInput))
640640
opts = append(opts, WithLoadOutput(false)) // Don't load output for queued workflows
641-
opts = append(opts, WithSortDesc(req.Body.SortDesc))
641+
opts = append(opts, WithSortDesc())
642642
opts = append(opts, WithQueuesOnly()) // Only include workflows that are in queues
643643

644644
// Add status filter for queued workflows

dbos/workflow.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,10 +1850,10 @@ func WithOffset(offset int) ListWorkflowsOption {
18501850
// Example:
18511851
//
18521852
// workflows, err := dbos.ListWorkflows(ctx,
1853-
// dbos.WithSortDesc(true))
1854-
func WithSortDesc(sortDesc bool) ListWorkflowsOption {
1853+
// dbos.WithSortDesc()
1854+
func WithSortDesc() ListWorkflowsOption {
18551855
return func(p *ListWorkflowsOptions) {
1856-
p.sortDesc = sortDesc
1856+
p.sortDesc = true
18571857
}
18581858
}
18591859

@@ -1970,7 +1970,7 @@ func WithExecutorIDs(executorIDs []string) ListWorkflowsOption {
19701970
// dbos.WithUser("john.doe"),
19711971
// dbos.WithOffset(50),
19721972
// dbos.WithLimit(25),
1973-
// dbos.WithSortDesc(true))
1973+
// dbos.WithSortDesc()
19741974
// if err != nil {
19751975
// log.Fatal(err)
19761976
// }

dbos/workflows_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ func TestGarbageCollect(t *testing.T) {
35253525
}
35263526

35273527
// Get timestamps for testing
3528-
workflows, err := ListWorkflows(dbosCtx, WithSortDesc(true))
3528+
workflows, err := ListWorkflows(dbosCtx, WithSortDesc())
35293529
require.NoError(t, err, "failed to list workflows")
35303530
require.Equal(t, numWorkflows, len(workflows))
35313531

@@ -3546,7 +3546,7 @@ func TestGarbageCollect(t *testing.T) {
35463546
})
35473547
require.NoError(t, err, "failed to garbage collect with threshold 6 and 7th newest timestamp")
35483548

3549-
workflows, err = ListWorkflows(dbosCtx, WithSortDesc(true))
3549+
workflows, err = ListWorkflows(dbosCtx, WithSortDesc())
35503550
require.NoError(t, err, "failed to list workflows after first GC")
35513551
require.Equal(t, threshold, len(workflows), "expected 6 workflows when threshold has more recent cutoff than timestamp")
35523552

@@ -3562,7 +3562,7 @@ func TestGarbageCollect(t *testing.T) {
35623562
})
35633563
require.NoError(t, err, "failed to garbage collect with threshold 3 and 2nd newest timestamp")
35643564

3565-
workflows, err = ListWorkflows(dbosCtx, WithSortDesc(true))
3565+
workflows, err = ListWorkflows(dbosCtx, WithSortDesc())
35663566
require.NoError(t, err, "failed to list workflows after second GC")
35673567
require.Equal(t, 2, len(workflows), "expected 2 workflows after second GC")
35683568
require.Equal(t, workflows[0].ID, handles[numWorkflows-1].GetWorkflowID(), "expected newest workflow to remain")

0 commit comments

Comments
 (0)