integration with parcoursmob
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m23s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m23s
This commit is contained in:
@@ -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")
|
||||
@@ -274,7 +281,7 @@ func (s MongoDBStorage) GetUserBookings(userid string) ([]internal.Booking, erro
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) UpdateBookingStatus(bookingid string, status string) error {
|
||||
//TODO implement UpdateBookingStatus
|
||||
// TODO implement UpdateBookingStatus
|
||||
return errors.New("MongoDB Storage - UpdateBookingStatus not implemented")
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user