add booking retrieval for user
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 32s

This commit is contained in:
2025-05-23 13:34:52 +02:00
parent 860e8122b2
commit 3d32c9a24a
4 changed files with 117 additions and 103 deletions

View File

@@ -37,7 +37,7 @@ func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyi
return &booking, nil
}
func (h Handler) GetBookings(startdate time.Time, enddate time.Time) ([]*types.Booking, error) {
func (h Handler) GetBookings(startdate time.Time, enddate time.Time, passengerid string) ([]*types.Booking, error) {
res := []*types.Booking{}
bookings, err := h.Storage.GetAllBookings()
@@ -48,7 +48,9 @@ func (h Handler) GetBookings(startdate time.Time, enddate time.Time) ([]*types.B
for _, b := range bookings {
if b.Journey.DriverDepartureDate.After(startdate) && b.Journey.DriverDepartureDate.Before(enddate) {
res = append(res, b)
if passengerid == "" || b.PassengerId == passengerid {
res = append(res, b)
}
}
}
return res, nil