Add PostgreSQL database option and more booking flow functionalities

This commit is contained in:
2023-05-08 01:29:59 +02:00
parent d8346a20be
commit e2e6759dc0
40 changed files with 1594 additions and 907 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/rs/zerolog/log"
)
// CreateRegularRoutes creates and stores a regular route
func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCollection) error {
groupid := uuid.NewString()
for _, r := range routes {
@@ -57,6 +58,7 @@ func (h *CarpoolServiceHandler) CreateRegularRoutes(routes []*geojson.FeatureCol
return nil
}
// 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) {
log.Debug().
Str("user_id", userid).
@@ -82,9 +84,9 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
for _, r := range routes {
rr := internal.RegularRoute(*r)
schedules, err := rr.PlannedJourneySchedules(minDepartureDate, maxDepartureDate)
schedules, err := rr.PlannedRouteSchedules(minDepartureDate, maxDepartureDate)
if err != nil {
log.Error().Err(err)
log.Error().Err(err).Msg("PlannedRouteSchedules error")
return nil, err
}
@@ -112,6 +114,7 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
return results, nil
}
// GetPlannedTrip returns a planned trip, given an ID. This should be called after getting the user planning from regular routes
func (h *CarpoolServiceHandler) GetPlannedTrip(id string) (*internal.PlannedRouteSchedule, error) {
planned_trip, err := h.Storage.GetRouteSchedule(id)
if err != nil {