We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 92352c7 commit d60d4b0Copy full SHA for d60d4b0
src/allocation/views.py
@@ -1,11 +1,9 @@
1
-from allocation.domain import model
2
from allocation.service_layer import unit_of_work
3
4
def allocations(orderid: str, uow: unit_of_work.SqlAlchemyUnitOfWork):
5
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]
+ results = list(uow.session.execute(
+ 'SELECT sku, batchref FROM allocations_view WHERE orderid = :orderid',
+ dict(orderid=orderid)
+ ))
+ return [dict(r) for r in results]
0 commit comments