Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip past due swap requests when calculating events #2718

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading