Skip to content

Commit 2f3a5a9

Browse files
committed
handlers talk to redis [redis_readmodel_handlers]
1 parent 508b734 commit 2f3a5a9

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/allocation/service_layer/handlers.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,8 @@ def publish_allocated_event(
7272
redis_eventpublisher.publish('line_allocated', event)
7373

7474

75-
def add_allocation_to_read_model(
76-
event: events.Allocated, uow: unit_of_work.SqlAlchemyUnitOfWork,
77-
):
78-
with uow:
79-
uow.session.execute(
80-
'INSERT INTO allocations_view (orderid, sku, batchref)'
81-
' VALUES (:orderid, :sku, :batchref)',
82-
dict(orderid=event.orderid, sku=event.sku, batchref=event.batchref)
83-
)
84-
uow.commit()
75+
def add_allocation_to_read_model(event: events.Allocated, _):
76+
redis_eventpublisher.update_readmodel(event.orderid, event.sku, event.batchref)
8577

86-
def remove_allocation_from_read_model(
87-
event: events.Deallocated, uow: unit_of_work.SqlAlchemyUnitOfWork,
88-
):
89-
with uow:
90-
uow.session.execute(
91-
'DELETE FROM allocations_view '
92-
' WHERE orderid = :orderid AND sku = :sku',
93-
dict(orderid=event.orderid, sku=event.sku)
94-
)
95-
uow.commit()
78+
def remove_allocation_from_read_model(event: events.Deallocated, _):
79+
redis_eventpublisher.update_readmodel(event.orderid, event.sku, None)

0 commit comments

Comments
 (0)