Improve passenger pickup/drop handling
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 3m8s

This commit is contained in:
Arnaud Delcasse
2025-09-25 06:36:14 +02:00
parent a95cd6eb55
commit b7ac71741f
14 changed files with 1042 additions and 2085 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -98,6 +98,8 @@ message DriverJourneysRequest {
optional double departure_radius = 7;
optional double arrival_radius = 8;
optional int64 count = 9;
optional string departure_address = 10;
optional string arrival_address = 11;
}
message DriverJourneysResponse {

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.24.4
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.31.1
// source: carpool-service.proto
package proto
@@ -15,8 +15,8 @@ import (
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
CarpoolService_CreateRegularRoutes_FullMethodName = "/CarpoolService/CreateRegularRoutes"
@@ -67,8 +67,9 @@ func NewCarpoolServiceClient(cc grpc.ClientConnInterface) CarpoolServiceClient {
}
func (c *carpoolServiceClient) CreateRegularRoutes(ctx context.Context, in *CreateRegularRoutesRequest, opts ...grpc.CallOption) (*CreateRegularRoutesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateRegularRoutesResponse)
err := c.cc.Invoke(ctx, CarpoolService_CreateRegularRoutes_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_CreateRegularRoutes_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -76,8 +77,9 @@ func (c *carpoolServiceClient) CreateRegularRoutes(ctx context.Context, in *Crea
}
func (c *carpoolServiceClient) DeleteRegularRoutes(ctx context.Context, in *DeleteRegularRoutesRequest, opts ...grpc.CallOption) (*DeleteRegularRoutesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeleteRegularRoutesResponse)
err := c.cc.Invoke(ctx, CarpoolService_DeleteRegularRoutes_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_DeleteRegularRoutes_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -85,8 +87,9 @@ func (c *carpoolServiceClient) DeleteRegularRoutes(ctx context.Context, in *Dele
}
func (c *carpoolServiceClient) GetRegularRoutes(ctx context.Context, in *GetRegularRoutesRequest, opts ...grpc.CallOption) (*GetRegularRoutesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetRegularRoutesResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetRegularRoutes_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetRegularRoutes_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -94,8 +97,9 @@ func (c *carpoolServiceClient) GetRegularRoutes(ctx context.Context, in *GetRegu
}
func (c *carpoolServiceClient) GetUserPlanning(ctx context.Context, in *GetUserPlanningRequest, opts ...grpc.CallOption) (*GetUserPlanningResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserPlanningResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetUserPlanning_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetUserPlanning_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -103,8 +107,9 @@ func (c *carpoolServiceClient) GetUserPlanning(ctx context.Context, in *GetUserP
}
func (c *carpoolServiceClient) GetPlannedTrip(ctx context.Context, in *GetPlannedTripRequest, opts ...grpc.CallOption) (*GetPlannedTripResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetPlannedTripResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetPlannedTrip_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetPlannedTrip_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -112,8 +117,9 @@ func (c *carpoolServiceClient) GetPlannedTrip(ctx context.Context, in *GetPlanne
}
func (c *carpoolServiceClient) GetUserBookings(ctx context.Context, in *GetUserBookingsRequest, opts ...grpc.CallOption) (*GetUserBookingsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserBookingsResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetUserBookings_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetUserBookings_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -121,8 +127,9 @@ func (c *carpoolServiceClient) GetUserBookings(ctx context.Context, in *GetUserB
}
func (c *carpoolServiceClient) GetCarpoolBookings(ctx context.Context, in *GetCarpoolBookingsRequest, opts ...grpc.CallOption) (*GetCarpoolBookingsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetCarpoolBookingsResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetCarpoolBookings_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetCarpoolBookings_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -130,8 +137,9 @@ func (c *carpoolServiceClient) GetCarpoolBookings(ctx context.Context, in *GetCa
}
func (c *carpoolServiceClient) DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DriverJourneysResponse)
err := c.cc.Invoke(ctx, CarpoolService_DriverJourneys_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_DriverJourneys_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -139,8 +147,9 @@ func (c *carpoolServiceClient) DriverJourneys(ctx context.Context, in *DriverJou
}
func (c *carpoolServiceClient) PassengerJourneys(ctx context.Context, in *PassengerJourneysRequest, opts ...grpc.CallOption) (*PassengerJourneysResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PassengerJourneysResponse)
err := c.cc.Invoke(ctx, CarpoolService_PassengerJourneys_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_PassengerJourneys_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -148,8 +157,9 @@ func (c *carpoolServiceClient) PassengerJourneys(ctx context.Context, in *Passen
}
func (c *carpoolServiceClient) DriverRegularTrips(ctx context.Context, in *DriverRegularTripsRequest, opts ...grpc.CallOption) (*DriverRegularTripsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DriverRegularTripsResponse)
err := c.cc.Invoke(ctx, CarpoolService_DriverRegularTrips_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_DriverRegularTrips_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -157,8 +167,9 @@ func (c *carpoolServiceClient) DriverRegularTrips(ctx context.Context, in *Drive
}
func (c *carpoolServiceClient) PassengerRegularTrips(ctx context.Context, in *PassengerRegularTripsRequest, opts ...grpc.CallOption) (*PassengerRegularTripsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PassengerRegularTripsResponse)
err := c.cc.Invoke(ctx, CarpoolService_PassengerRegularTrips_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_PassengerRegularTrips_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -166,8 +177,9 @@ func (c *carpoolServiceClient) PassengerRegularTrips(ctx context.Context, in *Pa
}
func (c *carpoolServiceClient) CreateBooking(ctx context.Context, in *CreateCarpoolBookingRequest, opts ...grpc.CallOption) (*CreateCarpoolBookingResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateCarpoolBookingResponse)
err := c.cc.Invoke(ctx, CarpoolService_CreateBooking_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_CreateBooking_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -175,8 +187,9 @@ func (c *carpoolServiceClient) CreateBooking(ctx context.Context, in *CreateCarp
}
func (c *carpoolServiceClient) UpdateBooking(ctx context.Context, in *UpdateCarpoolBookingRequest, opts ...grpc.CallOption) (*UpdateCarpoolBookingResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UpdateCarpoolBookingResponse)
err := c.cc.Invoke(ctx, CarpoolService_UpdateBooking_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_UpdateBooking_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -184,8 +197,9 @@ func (c *carpoolServiceClient) UpdateBooking(ctx context.Context, in *UpdateCarp
}
func (c *carpoolServiceClient) GetBooking(ctx context.Context, in *GetCarpoolBookingRequest, opts ...grpc.CallOption) (*GetCarpoolBookingResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetCarpoolBookingResponse)
err := c.cc.Invoke(ctx, CarpoolService_GetBooking_FullMethodName, in, out, opts...)
err := c.cc.Invoke(ctx, CarpoolService_GetBooking_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -194,7 +208,7 @@ func (c *carpoolServiceClient) GetBooking(ctx context.Context, in *GetCarpoolBoo
// CarpoolServiceServer is the server API for CarpoolService service.
// All implementations must embed UnimplementedCarpoolServiceServer
// for forward compatibility
// for forward compatibility.
type CarpoolServiceServer interface {
// Internal trips and journeys management
// rpc XXXX(Request) returns (Response) {}
@@ -216,9 +230,12 @@ type CarpoolServiceServer interface {
mustEmbedUnimplementedCarpoolServiceServer()
}
// UnimplementedCarpoolServiceServer must be embedded to have forward compatible implementations.
type UnimplementedCarpoolServiceServer struct {
}
// UnimplementedCarpoolServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedCarpoolServiceServer struct{}
func (UnimplementedCarpoolServiceServer) CreateRegularRoutes(context.Context, *CreateRegularRoutesRequest) (*CreateRegularRoutesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateRegularRoutes not implemented")
@@ -263,6 +280,7 @@ func (UnimplementedCarpoolServiceServer) GetBooking(context.Context, *GetCarpool
return nil, status.Errorf(codes.Unimplemented, "method GetBooking not implemented")
}
func (UnimplementedCarpoolServiceServer) mustEmbedUnimplementedCarpoolServiceServer() {}
func (UnimplementedCarpoolServiceServer) testEmbeddedByValue() {}
// UnsafeCarpoolServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CarpoolServiceServer will
@@ -272,6 +290,13 @@ type UnsafeCarpoolServiceServer interface {
}
func RegisterCarpoolServiceServer(s grpc.ServiceRegistrar, srv CarpoolServiceServer) {
// If the following call pancis, it indicates UnimplementedCarpoolServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&CarpoolService_ServiceDesc, srv)
}

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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

View File

@@ -6,6 +6,7 @@ import (
"git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss"
"github.com/paulmach/orb"
"github.com/paulmach/orb/geojson"
"github.com/rs/zerolog/log"
)
@@ -13,6 +14,10 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
departure := orb.Point{departureLng, departureLat}
arrival := orb.Point{arrivalLng, arrivalLat}
// Create features for the handler (OCSS doesn't provide addresses, so they'll be empty)
departureFeature := geojson.NewFeature(departure)
arrivalFeature := geojson.NewFeature(arrival)
td := 900 * time.Second
if timeDelta != nil {
td = *timeDelta
@@ -21,7 +26,7 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
minDate := departureDate.Add(-td * time.Second)
maxDate := departureDate.Add(td * time.Second)
journeys, err := s.Handler.GetDriverJourneys(departure, arrival, departureRadius, arrivalRadius, minDate, maxDate, count)
journeys, err := s.Handler.GetDriverJourneys(departureFeature, arrivalFeature, departureRadius, arrivalRadius, minDate, maxDate, count)
if err != nil {
return nil, err
}