Skip to content

Commit 337fae5

Browse files
committed
handlers talk to redis [redis_readmodel_handlers]
1 parent fee9a1e commit 337fae5

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/allocation/service_layer/handlers.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,9 @@ def publish_allocated_event(
8080
redis_eventpublisher.publish("line_allocated", event)
8181

8282

83-
def add_allocation_to_read_model(
84-
event: events.Allocated,
85-
uow: unit_of_work.SqlAlchemyUnitOfWork,
86-
):
87-
with uow:
88-
uow.session.execute(
89-
"""
90-
INSERT INTO allocations_view (orderid, sku, batchref)
91-
VALUES (:orderid, :sku, :batchref)
92-
""",
93-
dict(orderid=event.orderid, sku=event.sku, batchref=event.batchref),
94-
)
95-
uow.commit()
83+
def add_allocation_to_read_model(event: events.Allocated, _):
84+
redis_eventpublisher.update_readmodel(event.orderid, event.sku, event.batchref)
9685

9786

98-
def remove_allocation_from_read_model(
99-
event: events.Deallocated,
100-
uow: unit_of_work.SqlAlchemyUnitOfWork,
101-
):
102-
with uow:
103-
uow.session.execute(
104-
"""
105-
DELETE FROM allocations_view
106-
WHERE orderid = :orderid AND sku = :sku
107-
""",
108-
dict(orderid=event.orderid, sku=event.sku),
109-
)
110-
uow.commit()
87+
def remove_allocation_from_read_model(event: events.Deallocated, _):
88+
redis_eventpublisher.update_readmodel(event.orderid, event.sku, None)

0 commit comments

Comments
 (0)