@@ -80,31 +80,9 @@ def publish_allocated_event(
80
80
redis_eventpublisher .publish ("line_allocated" , event )
81
81
82
82
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 )
96
85
97
86
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