Skip past due swap requests when calculating events (#2718)

This commit is contained in:
Matias Bordese 2023-08-01 16:27:44 -03:00 committed by GitHub
parent 8db1ea5235
commit 2bc5c28777
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -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))

View file

@ -649,6 +649,9 @@ class OnCallSchedule(PolymorphicModel):
# 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)

View file

@ -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