Get all bookings
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 44s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 44s
This commit is contained in:
@@ -91,6 +91,32 @@ func (h *CarpoolServiceHandler) GetUserBookings(user_id string, mindate *time.Ti
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// GetBookings retrieves all the bookings between 2 dates
|
||||
func (h *CarpoolServiceHandler) GetBookings(mindate *time.Time, maxdate *time.Time) ([]internal.Booking, error) {
|
||||
bookings, err := h.Storage.GetAllBookings()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
results := []internal.Booking{}
|
||||
|
||||
for _, b := range bookings {
|
||||
if mindate != nil {
|
||||
if b.PassengerPickupDate.ToTime().Before(*mindate) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if maxdate != nil {
|
||||
if b.PassengerPickupDate.ToTime().After(*maxdate) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
results = append(results, b)
|
||||
}
|
||||
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user