GroupID management
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 3m9s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 3m9s
This commit is contained in:
@@ -161,3 +161,15 @@ func (s MemoryStorage) UpdateBookingStatus(bookingid string, newStatus string, r
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MemoryStorage) GetBookingsByGroupId(groupId string) ([]*types.Booking, error) {
|
||||
var bookings []*types.Booking
|
||||
|
||||
for _, booking := range s.Bookings {
|
||||
if booking.GroupId == groupId {
|
||||
bookings = append(bookings, booking)
|
||||
}
|
||||
}
|
||||
|
||||
return bookings, nil
|
||||
}
|
||||
|
||||
@@ -241,6 +241,20 @@ func (m *MockStorage) UpdateBookingStatus(bookingid string, newStatus string, re
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockStorage) GetBookingsByGroupId(groupId string) ([]*types.Booking, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
var bookings []*types.Booking
|
||||
for _, booking := range m.bookings {
|
||||
if booking.GroupId == groupId {
|
||||
bookings = append(bookings, booking)
|
||||
}
|
||||
}
|
||||
|
||||
return bookings, nil
|
||||
}
|
||||
|
||||
// Helper methods for testing
|
||||
|
||||
// Reset clears all data - useful for test setup
|
||||
|
||||
@@ -229,3 +229,20 @@ func (s MongoDBStorage) UpdateBookingStatus(bookingid string, newStatus string,
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) GetBookingsByGroupId(groupId string) ([]*types.Booking, error) {
|
||||
filter := bson.M{"groupid": groupId}
|
||||
|
||||
cursor, err := s.Collections.Bookings.Find(context.Background(), filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer cursor.Close(context.Background())
|
||||
|
||||
var bookings []*types.Booking
|
||||
if err := cursor.All(context.Background(), &bookings); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return bookings, nil
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type Storage interface {
|
||||
CreateBooking(types.Booking) error
|
||||
GetAllBookings() ([]*types.Booking, error)
|
||||
GetBooking(id string) (*types.Booking, error)
|
||||
GetBookingsByGroupId(groupId string) ([]*types.Booking, error)
|
||||
UpdateBooking(booking types.Booking) error
|
||||
UpdateBookingStatus(bookingid string, newStatus string, reason string) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user