Skip to content

Commit 98706ec

Browse files
authored
Fix: Retrieve latest input state instead of oldest (#1031)
* Add unit test to see if retrieve_input_state gets the latest user_input from DB * Change retrieve_input_state to retrieve latest input state instead of oldest * Fix codspeed action * bumpversion to 4.3.0rc3
1 parent 6182932 commit 98706ec

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.3.0rc2
2+
current_version = 4.3.0rc3
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(rc(?P<build>\d+))?

.github/workflows/run-codspeed-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Run benchmarks
1515
runs-on: ubuntu-latest
1616
container:
17-
image: python:3.13
17+
image: python:3.13-bookworm
1818
options: --privileged
1919
services:
2020
postgres:

orchestrator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
"""This is the orchestrator workflow engine."""
1515

16-
__version__ = "4.3.0rc2"
16+
__version__ = "4.3.0rc3"
1717

1818
from orchestrator.app import OrchestratorCore
1919
from orchestrator.settings import app_settings

orchestrator/services/input_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def retrieve_input_state(process_id: UUID, input_type: InputType, raise_exceptio
4141
select(InputStateTable)
4242
.filter(InputStateTable.process_id == process_id)
4343
.filter(InputStateTable.input_type == input_type)
44-
.order_by(InputStateTable.input_time.asc())
44+
.order_by(InputStateTable.input_time.desc())
4545
).first()
4646

4747
if res:

test/unit_tests/services/test_input_state.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime, timedelta, timezone
12
from uuid import uuid4
23

34
import pytest
@@ -60,3 +61,21 @@ def test_store_input_state(completed_process):
6061

6162
states = InputStateTable.query.all()
6263
assert len(states) == 2
64+
65+
66+
def test_retrieve_latest_input_state(completed_process):
67+
process_id, _ = completed_process
68+
69+
user_input_1 = InputStateTable(process_id=process_id, input_state={"first": "input"}, input_type="user_input")
70+
user_input_2 = InputStateTable(
71+
process_id=process_id,
72+
input_state={"second": "input"},
73+
input_type="user_input",
74+
input_time=(datetime.now(timezone.utc) + timedelta(hours=1)),
75+
)
76+
77+
db.session.add(user_input_1)
78+
db.session.add(user_input_2)
79+
db.session.commit()
80+
retrieved_state = retrieve_input_state(process_id, "user_input")
81+
assert retrieved_state == user_input_2

0 commit comments

Comments
 (0)