@@ -72,24 +72,8 @@ def publish_allocated_event(
72
72
redis_eventpublisher .publish ('line_allocated' , event )
73
73
74
74
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 )
85
77
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