Skip to content

Commit d60d4b0

Browse files
committed
Simpler view based on a new read model table
1 parent 92352c7 commit d60d4b0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/allocation/views.py

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

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

0 commit comments

Comments
 (0)