Esempio n. 1
0
def remove_allocation_from_read_model(event: events.Deallocated,
                                      uow: unit_of_work.SqlAlchemyUnitOfWork):
    with uow:
        uow.session.execute(
            'DELETE FROM allocations_view'
            ' WHERE orderid = :orderid AND sku = :sku',
            dict(orderid=event.orderid, sku=event.sku))
        uow.commit()
Esempio n. 2
0
def remove_allocation_from_read_model(event: events.Deallocated,
                                      uow: unit_of_work.SqlAlchemyUnitOfWork):
    with uow:
        uow.session.execute(
            'delete from allocations_view'
            ' where orderid=:orderid and sku=:sku',
            dict(orderid=event.orderid, sku=event.sku))
        uow.commit()
Esempio n. 3
0
def add_allocation_to_read_model(event: events.Allocated,
                                 uow: unit_of_work.SqlAlchemyUnitOfWork):
    with uow:
        uow.session.execute(
            'INSERT INTO allocations_view (orderid, sku, batchref)'
            ' VALUES (:orderid, :sku, :batchref)',
            dict(orderid=event.orderid, sku=event.sku,
                 batchref=event.batchref))
        uow.commit()
Esempio n. 4
0
def allocations_view_endpoint(orderid):
    uow = SqlAlchemyUnitOfWork()
    result = views.allocations(orderid, uow)
    if not result:
        return 'not fount', 404
    return jsonify(result), 200