Skip to content
This repository was archived by the owner on Aug 8, 2022. It is now read-only.

Commit 50905cf

Browse files
committed
Simpler view based on a new read model table
1 parent 71091ba commit 50905cf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/allocation/views.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from allocation.domain import model
21
from allocation.service_layer import unit_of_work
32

43

54
def allocations(orderid: str, uow: unit_of_work.SqlAlchemyUnitOfWork):
65
with uow:
7-
batches = (
8-
uow.session.query(model.Batch)
9-
.join(model.OrderLine, model.Batch._allocations)
10-
.filter(model.OrderLine.orderid == orderid)
6+
results = list(
7+
uow.session.execute(
8+
"SELECT sku, batchref FROM allocations_view WHERE orderid = :orderid",
9+
dict(orderid=orderid),
10+
)
1111
)
12-
return [{"sku": b.sku, "batchref": b.reference} for b in batches]
12+
return [dict(r) for r in results]

0 commit comments

Comments
 (0)