Booking
This commit is contained in:
@@ -4,21 +4,13 @@ import (
|
||||
"time"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/geoutils"
|
||||
"git.coopgo.io/coopgo-platform/routing-service"
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/internal"
|
||||
"git.coopgo.io/coopgo-platform/routing-service/encoding/polylines"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type SearchResult struct {
|
||||
ID string
|
||||
Route *geojson.FeatureCollection
|
||||
DepartureDate time.Time
|
||||
Itinerary *routing.Route
|
||||
}
|
||||
|
||||
func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]SearchResult, error) {
|
||||
func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]internal.SearchResult, error) {
|
||||
|
||||
log.Debug().
|
||||
Any("departure", departure).
|
||||
@@ -61,7 +53,7 @@ func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival o
|
||||
|
||||
candidate_routes := tileset.GetTiledRoutes()
|
||||
|
||||
journeys := []SearchResult{}
|
||||
journeys := []internal.SearchResult{}
|
||||
|
||||
counted := int64(0)
|
||||
for _, r := range candidate_routes {
|
||||
@@ -81,7 +73,7 @@ func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival o
|
||||
log.Error().Err(err).Msg("error getting route with viapoints")
|
||||
continue
|
||||
}
|
||||
journeys = append(journeys, SearchResult{
|
||||
journeys = append(journeys, internal.SearchResult{
|
||||
ID: r.ID,
|
||||
Route: r.Route,
|
||||
DepartureDate: r.DepartureDate,
|
||||
@@ -94,10 +86,16 @@ func (h *CarpoolServiceHandler) GetDriverJourneys(departure orb.Point, arrival o
|
||||
}
|
||||
}
|
||||
|
||||
err = h.Storage.StoreSearchResults("driver", journeys)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error saving search results")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return journeys, nil
|
||||
}
|
||||
|
||||
func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]SearchResult, error) {
|
||||
func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arrival orb.Point, departureRadius *float64, arrivalRadius *float64, minDate time.Time, maxDate time.Time, count *int64) ([]internal.SearchResult, error) {
|
||||
|
||||
log.Debug().
|
||||
Any("departure", departure).
|
||||
@@ -155,7 +153,7 @@ func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arriva
|
||||
|
||||
candidate_routes := tileset.GetTiledRoutes()
|
||||
|
||||
journeys := []SearchResult{}
|
||||
journeys := []internal.SearchResult{}
|
||||
|
||||
counted := int64(0)
|
||||
for _, r := range candidate_routes {
|
||||
@@ -173,7 +171,7 @@ func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arriva
|
||||
log.Error().Err(err).Msg("error getting route with viapoints")
|
||||
continue
|
||||
}
|
||||
journeys = append(journeys, SearchResult{
|
||||
journeys = append(journeys, internal.SearchResult{
|
||||
ID: r.ID,
|
||||
Route: r.Route,
|
||||
DepartureDate: r.DepartureDate,
|
||||
@@ -186,6 +184,12 @@ func (h *CarpoolServiceHandler) GetPassengerJourneys(departure orb.Point, arriva
|
||||
}
|
||||
}
|
||||
|
||||
err = h.Storage.StoreSearchResults("passenger", journeys)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error saving search results")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return journeys, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user