new grpc functions
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 34s

This commit is contained in:
2025-06-16 13:01:16 +02:00
parent 2f0a45ced0
commit d71da5accd
12 changed files with 472 additions and 220 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/rs/zerolog/log"
)
func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyid string, returnWaitingDuration time.Duration, data map[string]any) (*types.Booking, error) {
func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyid string, returnWaitingDuration time.Duration, priceAmount float64, priceCurrency string, data map[string]any) (*types.Booking, error) {
journey, err := h.Storage.GetDriverJourney(journeyid)
if err != nil {
log.Error().Err(err).Msg("could not find driver journey")
@@ -20,6 +20,11 @@ func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyi
return nil, errors.New("not authorized : journey id driver and driverid mismatch")
}
journey.Price.Amount = priceAmount
journey.Price.Currency = priceCurrency
log.Debug().Float64("Price", priceAmount).Any("journey", journey.Price).Msg("store booking")
booking := types.Booking{
Id: uuid.NewString(),
GroupId: uuid.NewString(),
@@ -72,8 +77,16 @@ func (h Handler) GetBooking(id string) (*types.Booking, error) {
return booking, nil
}
func (h Handler) UpdateBookingStatus(bookingid string, newStatus string) error {
if err := h.Storage.UpdateBookingStatus(bookingid, newStatus); err != nil {
func (h Handler) UpdateBooking(booking types.Booking) error {
if err := h.Storage.UpdateBooking(booking); err != nil {
log.Error().Err(err).Msg("could not update booking")
return err
}
return nil
}
func (h Handler) UpdateBookingStatus(bookingid string, newStatus string, reason string) error {
if err := h.Storage.UpdateBookingStatus(bookingid, newStatus, reason); err != nil {
log.Error().Err(err).Msg("could not update booking")
return err
}

View File

@@ -13,6 +13,7 @@ import (
)
func (h *Handler) GetDriverJourneys(departure *geojson.Feature, arrival *geojson.Feature, departureDate time.Time, noreturn bool) ([]*types.DriverJourney, error) {
log.Info().Time("departureDate", departureDate).Bool("noreturn", noreturn).Str("departure", departure.Properties.MustString("label")).Str("arrival", arrival.Properties.MustString("label")).Msg("calling GetDriverJourneys")
minDistance := h.Config.GetInt64("parameters.limits.distance.min")
maxDistance := h.Config.GetInt64("parameters.limits.distance.max")
day := int(departureDate.Weekday())
@@ -27,7 +28,6 @@ func (h *Handler) GetDriverJourneys(departure *geojson.Feature, arrival *geojson
}
for _, a := range availabilities {
log.Debug().Any("availability", a).Msg("Availability found")
if a.Address != nil {
var route *routing.Route
if noreturn {
@@ -55,8 +55,6 @@ func (h *Handler) GetDriverJourneys(departure *geojson.Feature, arrival *geojson
continue
}
log.Debug().Any("route", route).Msg("debug route")
passengerDistance := int64(route.Legs[1].Distance)
if !noreturn {
passengerDistance = passengerDistance + int64(route.Legs[2].Distance)
@@ -151,7 +149,6 @@ func (h Handler) ToggleDriverJourneyNoreturn(journeyid string) error {
journey.DriverDistance = int64(route.Distance)
journey.Duration = route.Legs[1].Duration
}
log.Debug().Any("journey", journey).Msg("journey update")
err = h.Storage.UpdateDriverJourney(*journey)
return err