def customers_to_jsonschema(customers_data: SuperDict): customersTimeWindows = [ SuperDict(id_customer=key, **tw) for key, time_windows in customers_data.get_property("timewindows").items() for tw in time_windows ] orders = [ SuperDict(id_customer=key, **order) for key, orders in customers_data.get_property("orders").items() for order in orders ] forecasts = [ SuperDict(id_customer=key, time=time, forecast=forecast) for key, forecasts in customers_data.get_property("Forecast").items() for time, forecast in enumerate(forecasts) if forecast > 0 ] allowedTrailers = [ SuperDict(id_location=key, id_trailer=id_trailer) for key, trailers in customers_data.get_property("allowedTrailers").items() for id_trailer in trailers ] customers = drop_props_get_values( customers_data, ["timewindows", "Forecast", "allowedTrailers", "orders"]) return SuperDict( customers=customers, customersTimeWindows=customersTimeWindows, orders=orders, forecasts=forecasts, allowedTrailers=allowedTrailers, )
def drivers_to_jsonschema(drivers_data: SuperDict): driversTimeWindows = [ dict(id_driver=key, **tw) for key, time_windows in drivers_data.get_property("timewindows").items() for tw in time_windows ] driversTrailers = [ SuperDict(id_driver=key, id_trailer=trailer) for key, trailers in drivers_data.get_property("trailer").items() for trailer in trailers ] drivers = drop_props_get_values(drivers_data, ["trailer", "timewindows"]) return SuperDict( drivers=drivers, driversTrailers=driversTrailers, driversTimeWindows=driversTimeWindows, )