diff --git a/orders_app/schemas/team_schema.py b/orders_app/schemas/team_schema.py index 78148ad..fc6075d 100644 --- a/orders_app/schemas/team_schema.py +++ b/orders_app/schemas/team_schema.py @@ -14,6 +14,8 @@ class OrderType(graphene.ObjectType): currency = graphene.String() sourceLocationUuid = graphene.String() sourceLocationName = graphene.String() + sourceLatitude = graphene.Float() + sourceLongitude = graphene.Float() destinationLocationUuid = graphene.String() destinationLocationName = graphene.String() createdAt = graphene.String() @@ -102,6 +104,12 @@ class TeamQuery(graphene.ObjectType): data = response.json() result = [] for order_data in data: + # Get source coordinates from first stage if not on order level + stages_data = order_data.get('stages', []) + first_stage = stages_data[0] if stages_data else {} + source_lat = order_data.get('source_latitude') or first_stage.get('source_latitude') + source_lon = order_data.get('source_longitude') or first_stage.get('source_longitude') + order = OrderType( uuid=order_data.get('uuid'), name=order_data.get('name'), @@ -112,6 +120,8 @@ class TeamQuery(graphene.ObjectType): currency=order_data.get('currency'), sourceLocationUuid=order_data.get('source_location_uuid'), sourceLocationName=order_data.get('source_location_name'), + sourceLatitude=source_lat, + sourceLongitude=source_lon, destinationLocationUuid=order_data.get('destination_location_uuid'), destinationLocationName=order_data.get('destination_location_name'), createdAt=order_data.get('created_at'), @@ -138,8 +148,14 @@ class TeamQuery(graphene.ObjectType): stageType=stage.get('stage_type'), transportType=stage.get('transport_type'), sourceLocationName=stage.get('source_location_name'), + sourceLatitude=stage.get('source_latitude'), + sourceLongitude=stage.get('source_longitude'), destinationLocationName=stage.get('destination_location_name'), + destinationLatitude=stage.get('destination_latitude'), + destinationLongitude=stage.get('destination_longitude'), locationName=stage.get('location_name'), + locationLatitude=stage.get('location_latitude'), + locationLongitude=stage.get('location_longitude'), selectedCompany=CompanyType( uuid=stage.get('selected_company', {}).get('uuid', ''), name=stage.get('selected_company', {}).get('name', ''),