Skip to content

Commit

Permalink
Skip past due swap requests when calculating events (#2718)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasb authored Aug 1, 2023
1 parent 8db1ea5 commit 2bc5c28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Skip past due swap requests when calculating events ([2718](https://github.com/grafana/oncall/pull/2718))

### Fixed

- Fix schedule final_events datetime filtering when splitting override ([#2715](https://github.com/grafana/oncall/pull/2715))
Expand Down
3 changes: 3 additions & 0 deletions engine/apps/schedules/models/on_call_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ def _insert_event(index: int, event: ScheduleEvent) -> int:

# apply swaps sequentially
for swap in swaps:
if swap.is_past_due:
# ignore untaken expired requests
continue
i = 0
while i < len(events):
event = events.pop(i)
Expand Down
5 changes: 5 additions & 0 deletions engine/apps/schedules/tests/test_on_call_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2329,11 +2329,16 @@ def test_swap_request_no_changes(

# setup swap requests
tomorrow = today + timezone.timedelta(days=1)
# user not in schedule
make_shift_swap_request(schedule, other_user, swap_start=today, swap_end=tomorrow)
# deleted request
make_shift_swap_request(schedule, user, swap_start=today, swap_end=tomorrow, deleted_at=today)
# swap request in the past
make_shift_swap_request(
schedule, user, swap_start=today - timezone.timedelta(days=7), swap_end=tomorrow - timezone.timedelta(days=7)
)
# untaken swap in progress (past due)
make_shift_swap_request(schedule, user, swap_start=today - timezone.timedelta(days=1), swap_end=tomorrow)

events_after = schedule.filter_events(today, today + timezone.timedelta(days=2))
assert events_before == events_after

0 comments on commit 2bc5c28

Please sign in to comment.