Skip to content

Commit d746728

Browse files
committed
handler for view model update
1 parent eefded6 commit d746728

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/allocation/service_layer/handlers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,15 @@ def publish_allocated_event(
6161
event: events.Allocated, uow: unit_of_work.AbstractUnitOfWork,
6262
):
6363
redis_eventpublisher.publish('line_allocated', event)
64+
65+
66+
def add_allocation_to_read_model(
67+
event: events.Allocated, uow: unit_of_work.SqlAlchemyUnitOfWork,
68+
):
69+
with uow:
70+
uow.session.execute(
71+
'INSERT INTO allocations_view (orderid, sku, batchref)'
72+
' VALUES (:orderid, :sku, :batchref)',
73+
dict(orderid=event.orderid, sku=event.sku, batchref=event.batchref)
74+
)
75+
uow.commit()

0 commit comments

Comments
 (0)