Improve passenger pickup/drop handling
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 3m8s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 3m8s
This commit is contained in:
@@ -12,11 +12,13 @@ import (
|
||||
|
||||
func (s *CarpoolServiceServerImpl) CreateBooking(ctx context.Context, req *proto.CreateCarpoolBookingRequest) (*proto.CreateCarpoolBookingResponse, error) {
|
||||
booking := req.Booking.ToOCSS()
|
||||
_, err := s.Handler.Book(booking)
|
||||
createdBooking, err := s.Handler.Book(booking)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "could not create booking - %s", err.Error())
|
||||
}
|
||||
return &proto.CreateCarpoolBookingResponse{}, nil
|
||||
return &proto.CreateCarpoolBookingResponse{
|
||||
Booking: proto.BookingFromInternal(*createdBooking),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *CarpoolServiceServerImpl) GetUserBookings(ctx context.Context, req *proto.GetUserBookingsRequest) (*proto.GetUserBookingsResponse, error) {
|
||||
|
||||
@@ -82,10 +82,11 @@ func (s *CarpoolServiceServerImpl) GetUserPlanning(ctx context.Context, req *pro
|
||||
Collection: []*proto.CarpoolFeatureCollection{},
|
||||
}
|
||||
|
||||
for _, s := range scheds {
|
||||
s.Route.ExtraMembers["departure_date"] = s.DepartureDate
|
||||
s.Route.ExtraMembers["id"] = s.ID
|
||||
fcraw, _ := s.Route.MarshalJSON()
|
||||
for _, sched := range scheds {
|
||||
sched.Route.ExtraMembers["departure_date"] = sched.DepartureDate
|
||||
sched.Route.ExtraMembers["id"] = sched.ID
|
||||
sched.Route.ExtraMembers["operator"] = s.Handler.InternalOperatorID
|
||||
fcraw, _ := sched.Route.MarshalJSON()
|
||||
results[k].Collection = append(results[k].Collection, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(fcraw),
|
||||
})
|
||||
@@ -106,6 +107,15 @@ func (s *CarpoolServiceServerImpl) GetPlannedTrip(ctx context.Context, req *prot
|
||||
|
||||
planned_trip.Route.ExtraMembers["id"] = planned_trip.ID
|
||||
planned_trip.Route.ExtraMembers["departure_date"] = planned_trip.DepartureDate
|
||||
planned_trip.Route.ExtraMembers["operator"] = s.Handler.InternalOperatorID
|
||||
|
||||
// Add passenger pickup and drop information to extra members for frontend access
|
||||
if planned_trip.PassengerPickup != nil {
|
||||
planned_trip.Route.ExtraMembers["passenger_pickup"] = planned_trip.PassengerPickup
|
||||
}
|
||||
if planned_trip.PassengerDrop != nil {
|
||||
planned_trip.Route.ExtraMembers["passenger_drop"] = planned_trip.PassengerDrop
|
||||
}
|
||||
|
||||
serialized, err := planned_trip.Route.MarshalJSON()
|
||||
if err != nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/servers/grpc/proto"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -16,6 +17,24 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
|
||||
departure := orb.Point{req.DepartureLng, req.DepartureLat}
|
||||
arrival := orb.Point{req.ArrivalLng, req.ArrivalLat}
|
||||
|
||||
// Create features with addresses
|
||||
departureFeature := geojson.NewFeature(departure)
|
||||
arrivalFeature := geojson.NewFeature(arrival)
|
||||
|
||||
if req.DepartureAddress != nil && *req.DepartureAddress != "" {
|
||||
if departureFeature.Properties == nil {
|
||||
departureFeature.Properties = make(map[string]interface{})
|
||||
}
|
||||
departureFeature.Properties["label"] = *req.DepartureAddress
|
||||
}
|
||||
|
||||
if req.ArrivalAddress != nil && *req.ArrivalAddress != "" {
|
||||
if arrivalFeature.Properties == nil {
|
||||
arrivalFeature.Properties = make(map[string]interface{})
|
||||
}
|
||||
arrivalFeature.Properties["label"] = *req.ArrivalAddress
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
Str("departure date", req.DepartureDate.String()).
|
||||
Any("departure", departure).
|
||||
@@ -39,7 +58,7 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
|
||||
Int64("td", int64(td)).
|
||||
Msg("DriverJourneys show dates")
|
||||
|
||||
journeys, err := s.Handler.GetDriverJourneys(departure, arrival, req.DepartureRadius, req.ArrivalRadius, minDate, maxDate, req.Count)
|
||||
journeys, err := s.Handler.GetDriverJourneys(departureFeature, arrivalFeature, req.DepartureRadius, req.ArrivalRadius, minDate, maxDate, req.Count)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error finding driver journeys")
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user