update
This commit is contained in:
@@ -91,6 +91,7 @@ func (h *CarpoolServiceHandler) GetUserBookings(user_id string, mindate *time.Ti
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// UpdateBookingStatus sets a new status for a given booking id
|
||||
func (h *CarpoolServiceHandler) UpdateBookingStatus(id string, status ocss.BookingStatus) error {
|
||||
err := h.Storage.UpdateBookingStatus(id, status.String())
|
||||
if err != nil {
|
||||
|
||||
@@ -16,6 +16,7 @@ type CarpoolServiceHandler struct {
|
||||
InternalOperatorID string
|
||||
}
|
||||
|
||||
// NewCarpoolServiceHandler initiates the carpool service handler, implementing the COOPGO Carpool Service business logic
|
||||
func NewCarpoolServiceHandler(cfg *viper.Viper, storage storage.Storage, tilesHandler *tiles.TilesHandler, routing routing.RoutingService) (*CarpoolServiceHandler, error) {
|
||||
operator := cfg.GetString("interoperability.internal_operator_id")
|
||||
return &CarpoolServiceHandler{
|
||||
|
||||
@@ -59,7 +59,7 @@ func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCol
|
||||
}
|
||||
|
||||
// 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) (map[string][]internal.PlannedRouteSchedule, error) {
|
||||
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().
|
||||
Str("user_id", userid).
|
||||
Time("min_departure_date", minDepartureDate).
|
||||
@@ -77,7 +77,11 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
|
||||
routes, err := h.Storage.GetUserRegularRoutes(userid)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error in storage - GetUserRegularRoutes")
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
if len(routes) == 0 {
|
||||
return results, true, nil
|
||||
}
|
||||
|
||||
all_schedules := []internal.PlannedRouteSchedule{}
|
||||
@@ -87,7 +91,7 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
|
||||
schedules, err := rr.PlannedRouteSchedules(minDepartureDate, maxDepartureDate)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("PlannedRouteSchedules error")
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
all_schedules = append(all_schedules, schedules...)
|
||||
@@ -107,11 +111,11 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
|
||||
err = h.Storage.StoreRouteSchedules(all_schedules)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("could not store route schedules")
|
||||
return nil, err
|
||||
return nil, false, err
|
||||
}
|
||||
}
|
||||
|
||||
return results, nil
|
||||
return results, false, nil
|
||||
}
|
||||
|
||||
// GetPlannedTrip returns a planned trip, given an ID. This should be called after getting the user planning from regular routes
|
||||
|
||||
Reference in New Issue
Block a user