integration with parcoursmob
Build and Push Docker Image / build_and_push (push) Failing after 2m23s
Details
Build and Push Docker Image / build_and_push (push) Failing after 2m23s
Details
This commit is contained in:
parent
d465ef56c9
commit
4718de6c80
|
@ -58,6 +58,23 @@ func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCol
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h *CarpoolServiceHandler) GetUserRegularRoutes(userid string) ([]*geojson.FeatureCollection, error) {
|
||||
routes, err := h.Storage.GetUserRegularRoutes(userid)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error in storage - GetUserRegularRoutes")
|
||||
return nil, err
|
||||
}
|
||||
return routes, nil
|
||||
}
|
||||
|
||||
func (h *CarpoolServiceHandler) DeleteRegularRoutes(ids []string) (err error) {
|
||||
err = h.Storage.DeleteRegularRoutes(ids)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error deleteing regular routes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// GetUserPlanning returns the planned routes for a user between 2 dates. It transforms regular routes to multiple indivual planned route schedules
|
||||
func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate time.Time, maxDepartureDate time.Time) (planned_schedules map[string][]internal.PlannedRouteSchedule, missing_planning bool, err error) {
|
||||
log.Debug().
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
// GetDriverJourneys searches for matching punctual planned driver journeys.
|
||||
func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]internal.PlannedRouteSchedule, error) {
|
||||
|
||||
log.Debug().
|
||||
Any("departure", departure).
|
||||
Any("arrival", arrival).
|
||||
|
@ -96,7 +95,6 @@ func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival o
|
|||
|
||||
// GetPassengerJourneys searches for matching punctual planned passenger journeys.
|
||||
func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]internal.PlannedRouteSchedule, error) {
|
||||
|
||||
log.Debug().
|
||||
Any("departure", departure).
|
||||
Any("arrival", arrival).
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@ service CarpoolService {
|
|||
// rpc XXXX(Request) returns (Response) {}
|
||||
rpc CreateRegularRoutes(CreateRegularRoutesRequest) returns (CreateRegularRoutesResponse) {}
|
||||
rpc DeleteRegularRoutes(DeleteRegularRoutesRequest) returns (DeleteRegularRoutesResponse) {}
|
||||
rpc GetRegularRoutes(GetRegularRoutesRequest) returns (GetRegularRoutesResponse) {}
|
||||
rpc GetUserPlanning(GetUserPlanningRequest) returns (GetUserPlanningResponse) {}
|
||||
rpc GetPlannedTrip(GetPlannedTripRequest) returns (GetPlannedTripResponse) {}
|
||||
rpc GetUserBookings(GetUserBookingsRequest) returns (GetUserBookingsResponse) {}
|
||||
|
@ -37,6 +38,14 @@ message DeleteRegularRoutesRequest {
|
|||
|
||||
message DeleteRegularRoutesResponse {}
|
||||
|
||||
message GetRegularRoutesRequest {
|
||||
string user_id = 1;
|
||||
}
|
||||
|
||||
message GetRegularRoutesResponse {
|
||||
repeated CarpoolFeatureCollection routes = 1;
|
||||
}
|
||||
|
||||
message GetUserPlanningRequest {
|
||||
string user_id = 1;
|
||||
google.protobuf.Timestamp min_departure_date = 2;
|
||||
|
|
|
@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7
|
|||
const (
|
||||
CarpoolService_CreateRegularRoutes_FullMethodName = "/CarpoolService/CreateRegularRoutes"
|
||||
CarpoolService_DeleteRegularRoutes_FullMethodName = "/CarpoolService/DeleteRegularRoutes"
|
||||
CarpoolService_GetRegularRoutes_FullMethodName = "/CarpoolService/GetRegularRoutes"
|
||||
CarpoolService_GetUserPlanning_FullMethodName = "/CarpoolService/GetUserPlanning"
|
||||
CarpoolService_GetPlannedTrip_FullMethodName = "/CarpoolService/GetPlannedTrip"
|
||||
CarpoolService_GetUserBookings_FullMethodName = "/CarpoolService/GetUserBookings"
|
||||
|
@ -41,6 +42,7 @@ type CarpoolServiceClient interface {
|
|||
// rpc XXXX(Request) returns (Response) {}
|
||||
CreateRegularRoutes(ctx context.Context, in *CreateRegularRoutesRequest, opts ...grpc.CallOption) (*CreateRegularRoutesResponse, error)
|
||||
DeleteRegularRoutes(ctx context.Context, in *DeleteRegularRoutesRequest, opts ...grpc.CallOption) (*DeleteRegularRoutesResponse, error)
|
||||
GetRegularRoutes(ctx context.Context, in *GetRegularRoutesRequest, opts ...grpc.CallOption) (*GetRegularRoutesResponse, error)
|
||||
GetUserPlanning(ctx context.Context, in *GetUserPlanningRequest, opts ...grpc.CallOption) (*GetUserPlanningResponse, error)
|
||||
GetPlannedTrip(ctx context.Context, in *GetPlannedTripRequest, opts ...grpc.CallOption) (*GetPlannedTripResponse, error)
|
||||
GetUserBookings(ctx context.Context, in *GetUserBookingsRequest, opts ...grpc.CallOption) (*GetUserBookingsResponse, error)
|
||||
|
@ -80,6 +82,15 @@ func (c *carpoolServiceClient) DeleteRegularRoutes(ctx context.Context, in *Dele
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *carpoolServiceClient) GetRegularRoutes(ctx context.Context, in *GetRegularRoutesRequest, opts ...grpc.CallOption) (*GetRegularRoutesResponse, error) {
|
||||
out := new(GetRegularRoutesResponse)
|
||||
err := c.cc.Invoke(ctx, CarpoolService_GetRegularRoutes_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *carpoolServiceClient) GetUserPlanning(ctx context.Context, in *GetUserPlanningRequest, opts ...grpc.CallOption) (*GetUserPlanningResponse, error) {
|
||||
out := new(GetUserPlanningResponse)
|
||||
err := c.cc.Invoke(ctx, CarpoolService_GetUserPlanning_FullMethodName, in, out, opts...)
|
||||
|
@ -178,6 +189,7 @@ type CarpoolServiceServer interface {
|
|||
// rpc XXXX(Request) returns (Response) {}
|
||||
CreateRegularRoutes(context.Context, *CreateRegularRoutesRequest) (*CreateRegularRoutesResponse, error)
|
||||
DeleteRegularRoutes(context.Context, *DeleteRegularRoutesRequest) (*DeleteRegularRoutesResponse, error)
|
||||
GetRegularRoutes(context.Context, *GetRegularRoutesRequest) (*GetRegularRoutesResponse, error)
|
||||
GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error)
|
||||
GetPlannedTrip(context.Context, *GetPlannedTripRequest) (*GetPlannedTripResponse, error)
|
||||
GetUserBookings(context.Context, *GetUserBookingsRequest) (*GetUserBookingsResponse, error)
|
||||
|
@ -202,6 +214,9 @@ func (UnimplementedCarpoolServiceServer) CreateRegularRoutes(context.Context, *C
|
|||
func (UnimplementedCarpoolServiceServer) DeleteRegularRoutes(context.Context, *DeleteRegularRoutesRequest) (*DeleteRegularRoutesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteRegularRoutes not implemented")
|
||||
}
|
||||
func (UnimplementedCarpoolServiceServer) GetRegularRoutes(context.Context, *GetRegularRoutesRequest) (*GetRegularRoutesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetRegularRoutes not implemented")
|
||||
}
|
||||
func (UnimplementedCarpoolServiceServer) GetUserPlanning(context.Context, *GetUserPlanningRequest) (*GetUserPlanningResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetUserPlanning not implemented")
|
||||
}
|
||||
|
@ -281,6 +296,24 @@ func _CarpoolService_DeleteRegularRoutes_Handler(srv interface{}, ctx context.Co
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CarpoolService_GetRegularRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetRegularRoutesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CarpoolServiceServer).GetRegularRoutes(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CarpoolService_GetRegularRoutes_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CarpoolServiceServer).GetRegularRoutes(ctx, req.(*GetRegularRoutesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CarpoolService_GetUserPlanning_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUserPlanningRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
@ -476,6 +509,10 @@ var CarpoolService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "DeleteRegularRoutes",
|
||||
Handler: _CarpoolService_DeleteRegularRoutes_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetRegularRoutes",
|
||||
Handler: _CarpoolService_GetRegularRoutes_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUserPlanning",
|
||||
Handler: _CarpoolService_GetUserPlanning_Handler,
|
||||
|
|
|
@ -32,12 +32,42 @@ func (s *CarpoolServiceServerImpl) CreateRegularRoutes(ctx context.Context, req
|
|||
return &proto.CreateRegularRoutesResponse{}, nil
|
||||
}
|
||||
|
||||
func (s *CarpoolServiceServerImpl) DeleteRegularRoutes(context.Context, *proto.DeleteRegularRoutesRequest) (*proto.DeleteRegularRoutesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteTrips not implemented")
|
||||
func (s *CarpoolServiceServerImpl) DeleteRegularRoutes(ctx context.Context, req *proto.DeleteRegularRoutesRequest) (*proto.DeleteRegularRoutesResponse, error) {
|
||||
err := s.Handler.DeleteRegularRoutes(req.Ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.DeleteRegularRoutesResponse{}, nil
|
||||
}
|
||||
|
||||
func (s *CarpoolServiceServerImpl) GetRegularRoutes(ctx context.Context, req *proto.GetRegularRoutesRequest) (*proto.GetRegularRoutesResponse, error) {
|
||||
log.Debug().Msg("grpc CarpoolService - GetRegularRoutes")
|
||||
|
||||
routes, err := s.Handler.GetUserRegularRoutes(req.UserId)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "could not retrieve user routes : %s", err.Error())
|
||||
}
|
||||
|
||||
results := []*proto.CarpoolFeatureCollection{}
|
||||
|
||||
for _, r := range routes {
|
||||
serialized, err := r.MarshalJSON()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error marshaling route")
|
||||
continue
|
||||
}
|
||||
results = append(results, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(serialized),
|
||||
})
|
||||
}
|
||||
|
||||
return &proto.GetRegularRoutesResponse{
|
||||
Routes: results,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *CarpoolServiceServerImpl) GetUserPlanning(ctx context.Context, req *proto.GetUserPlanningRequest) (*proto.GetUserPlanningResponse, error) {
|
||||
log.Debug().Msg("grpc CarpoolService - GetRegularUserRoutes")
|
||||
log.Debug().Msg("grpc CarpoolService - GetUserPlanning")
|
||||
|
||||
planned_schedules, missing_planning, err := s.Handler.GetUserPlanning(req.UserId, req.MinDepartureDate.AsTime(), req.MaxDepartureDate.AsTime())
|
||||
if err != nil {
|
||||
|
|
|
@ -71,12 +71,22 @@ func (s *CarpoolServiceServerImpl) DriverJourneys(ctx context.Context, req *prot
|
|||
distance = &dist
|
||||
}
|
||||
|
||||
operator := "internal"
|
||||
if usermap["operator"] != nil {
|
||||
operator = usermap["operator"].(string)
|
||||
}
|
||||
|
||||
alias := ""
|
||||
if usermap["alias"] != nil {
|
||||
alias = usermap["alias"].(string)
|
||||
}
|
||||
|
||||
results = append(results, &proto.CarpoolServiceDriverJourney{
|
||||
Id: journeyId,
|
||||
Driver: &proto.CarpoolServiceUser{
|
||||
Id: usermap["id"].(string),
|
||||
Operator: usermap["operator"].(string),
|
||||
Alias: usermap["alias"].(string),
|
||||
Operator: operator,
|
||||
Alias: alias,
|
||||
},
|
||||
Operator: s.Handler.InternalOperatorID,
|
||||
PassengerPickupLat: req.DepartureLat,
|
||||
|
|
|
@ -46,7 +46,6 @@ func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error) {
|
|||
}
|
||||
|
||||
err = client.Connect(context.TODO())
|
||||
|
||||
if err != nil {
|
||||
return MongoDBStorage{}, err
|
||||
}
|
||||
|
@ -68,7 +67,6 @@ func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error) {
|
|||
}
|
||||
|
||||
func (s MongoDBStorage) CreateRegularRoutes(routes []*geojson.FeatureCollection) error {
|
||||
|
||||
log.Debug().Msg("Storage - CreateRegularRoutes")
|
||||
|
||||
documents := []any{}
|
||||
|
@ -180,6 +178,15 @@ func (s MongoDBStorage) GetDriverRegularRoutesForTile(day string, gridId int64)
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) DeleteRegularRoutes(ids []string) error {
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["regular_routes"])
|
||||
_, err := collection.DeleteMany(context.Background(), bson.M{"_id": bson.M{"$in": ids}})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error deleteing regular routes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) GetPassengerRegularRoutesForTile(day string, gridId int64) ([]*geojson.FeatureCollection, error) {
|
||||
findOptions := options.Find()
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["regular_routes"])
|
||||
|
@ -224,7 +231,6 @@ func (s MongoDBStorage) GetPassengerRegularRoutesForTile(day string, gridId int6
|
|||
}
|
||||
|
||||
func (s MongoDBStorage) CreateBooking(booking internal.Booking) error {
|
||||
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["bookings"])
|
||||
_, err := collection.InsertOne(context.TODO(), booking)
|
||||
if err != nil {
|
||||
|
@ -232,6 +238,7 @@ func (s MongoDBStorage) CreateBooking(booking internal.Booking) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) GetBooking(id string) (booking *internal.Booking, err error) {
|
||||
var b internal.Booking
|
||||
log.Debug().Str("booking id", id).Msg("get booking in DB")
|
||||
|
@ -286,6 +293,7 @@ func (s MongoDBStorage) PersistedKVPut(documents []any) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) PersistedKVGet(id string, document any) error {
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["persisted_kv"])
|
||||
err := collection.FindOne(context.TODO(), bson.M{"_id": id}).Decode(document)
|
||||
|
@ -296,7 +304,6 @@ func (s MongoDBStorage) PersistedKVGet(id string, document any) error {
|
|||
}
|
||||
|
||||
func (s MongoDBStorage) StoreRouteSchedules(js []internal.PlannedRouteSchedule) error {
|
||||
|
||||
log.Debug().Msg("Storage - StoreRouteSchedules")
|
||||
|
||||
documents := []any{}
|
||||
|
@ -308,7 +315,6 @@ func (s MongoDBStorage) StoreRouteSchedules(js []internal.PlannedRouteSchedule)
|
|||
}
|
||||
|
||||
func (s MongoDBStorage) GetRouteSchedule(id string) (*internal.PlannedRouteSchedule, error) {
|
||||
|
||||
var result internal.PlannedRouteSchedule
|
||||
err := s.PersistedKVGet(id, &result)
|
||||
if err != nil {
|
||||
|
|
|
@ -68,7 +68,6 @@ func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error) {
|
|||
}
|
||||
|
||||
func (s PostgresqlStorage) CreateRegularRoutes(routes []*geojson.FeatureCollection) error {
|
||||
|
||||
log.Debug().Msg("Postgresql Storage - CreateRegularRoutes")
|
||||
|
||||
tx, err := s.DbConnection.Begin()
|
||||
|
@ -175,6 +174,15 @@ func (s PostgresqlStorage) GetUserRegularRoutes(userid string) ([]*geojson.Featu
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func (s PostgresqlStorage) DeleteRegularRoutes(ids []string) error {
|
||||
req := fmt.Sprintf(`delete from %s where id in $1`, s.Tables["regular_routes"])
|
||||
_, err := s.DbConnection.Exec(req, ids)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error in postgresql request - delete regular routes")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s PostgresqlStorage) GetDriverRegularRoutesForTile(day string, gridId int64) (regular_routes []*geojson.FeatureCollection, err error) {
|
||||
req := fmt.Sprintf(`select id, route
|
||||
from %s inner join %s on id = route_id
|
||||
|
@ -434,8 +442,8 @@ func (s PostgresqlStorage) StoreRouteSchedules(journeys []internal.PlannedRouteS
|
|||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (s PostgresqlStorage) GetRouteSchedule(id string) (*internal.PlannedRouteSchedule, error) {
|
||||
req := fmt.Sprintf("select data from %s where id = $1", s.Tables["journeys_cache"])
|
||||
var jsonjourney []byte
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
type Storage interface {
|
||||
CreateRegularRoutes([]*geojson.FeatureCollection) error
|
||||
GetUserRegularRoutes(userid string) ([]*geojson.FeatureCollection, error)
|
||||
DeleteRegularRoutes(ids []string) error
|
||||
GetDriverRegularRoutesForTile(day string, gridId int64) ([]*geojson.FeatureCollection, error)
|
||||
GetPassengerRegularRoutesForTile(day string, gridId int64) ([]*geojson.FeatureCollection, error)
|
||||
|
||||
|
@ -29,9 +30,7 @@ type Storage interface {
|
|||
}
|
||||
|
||||
func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
var (
|
||||
storage_type = cfg.GetString("storage.db.type")
|
||||
)
|
||||
storage_type := cfg.GetString("storage.db.type")
|
||||
|
||||
switch storage_type {
|
||||
case "mongodb":
|
||||
|
|
Loading…
Reference in New Issue