Skip to content

Commit

Permalink
374 Fix active reservations boundary logic (#375)
Browse files Browse the repository at this point in the history
* Update filters to show active reservations on ambassador view

* Fix bug when start_idx < 0

* Only consider rooms that are present in map

---------

Co-authored-by: Yuvraj Jain <[email protected]>
  • Loading branch information
aarjavjain2002 and yuvrajjain2003 authored Mar 29, 2024
1 parent 6223208 commit b29e7f6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions backend/services/coworking/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,9 @@ def get_map_reserved_times_by_date(
)
end_idx = self._idx_calculation(reservation.end, operating_hours_start)

if start_idx < 0 or end_idx > operating_hours_duration:
if end_idx < current_time_idx:
continue

# Gray out previous time slots for today only
if date.date() == current_time.date():
if end_idx < current_time_idx:
continue
start_idx = max(current_time_idx, start_idx)
start_idx = max(current_time_idx, start_idx)

for idx in range(start_idx, end_idx):
# Currently only assuming single user.
Expand Down Expand Up @@ -468,6 +463,8 @@ def _transform_date_map_for_officehours(
"""
office_hours = self._policy_svc.office_hours(date=date)
for room_id, hours in office_hours.items():
if room_id not in reserved_date_map:
continue
for start, end in hours:
start_idx = max(self._idx_calculation(start, operating_hours_start), 0)
end_idx = min(
Expand Down Expand Up @@ -1040,7 +1037,7 @@ def list_all_active_and_upcoming_for_rooms(
self._session.query(ReservationEntity)
.join(ReservationEntity.users)
.filter(
ReservationEntity.start >= now - timedelta(minutes=10),
ReservationEntity.end > now,
ReservationEntity.state.in_(
(
ReservationState.CONFIRMED,
Expand Down

0 comments on commit b29e7f6

Please sign in to comment.