Skip to content

Commit 974ffad

Browse files
authored
Consistent Sort Order (#207)
All list workflows command should sort in ascending order (most recently started workflows last).
1 parent 1553d98 commit 974ffad

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

dbos/_sys_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def get_workflow_inputs(
672672

673673
def get_workflows(self, input: GetWorkflowsInput) -> GetWorkflowsOutput:
674674
query = sa.select(SystemSchema.workflow_status.c.workflow_uuid).order_by(
675-
SystemSchema.workflow_status.c.created_at.desc()
675+
SystemSchema.workflow_status.c.created_at.asc()
676676
)
677677
if input.name:
678678
query = query.where(SystemSchema.workflow_status.c.name == input.name)
@@ -718,7 +718,7 @@ def get_queued_workflows(
718718
SystemSchema.workflow_queue.c.workflow_uuid
719719
== SystemSchema.workflow_status.c.workflow_uuid,
720720
)
721-
.order_by(SystemSchema.workflow_status.c.created_at.desc())
721+
.order_by(SystemSchema.workflow_status.c.created_at.asc())
722722
)
723723

724724
if input.get("name"):

tests/test_dbos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,10 @@ def test_send_recv_workflow(topic: str) -> str:
905905

906906
wfs = dbos._sys_db.get_workflows(gwi)
907907
assert len(wfs.workflow_uuids) == 2
908-
assert wfs.workflow_uuids[1] == dest_uuid
909-
assert wfs.workflow_uuids[0] != dest_uuid
908+
assert wfs.workflow_uuids[0] == dest_uuid
909+
assert wfs.workflow_uuids[1] != dest_uuid
910910

911-
wfi = dbos._sys_db.get_workflow_info(wfs.workflow_uuids[0], False)
911+
wfi = dbos._sys_db.get_workflow_info(wfs.workflow_uuids[1], False)
912912
assert wfi
913913
assert wfi["name"] == "<temp>.temp_send_workflow"
914914

tests/test_workflow_cmds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ def blocking_step(i: int) -> int:
245245
assert workflow.status == WorkflowStatusString.PENDING.value
246246
assert workflow.queue_name == queue.name
247247
assert workflow.input is not None
248-
# Verify newest queue entries appear first
249-
assert workflow.input["args"][0] == queued_steps - i - 1
248+
# Verify oldest queue entries appear first
249+
assert workflow.input["args"][0] == i
250250
assert workflow.output is None
251251
assert workflow.error is None
252252
assert "blocking_step" in workflow.workflowName

0 commit comments

Comments
 (0)