Skip past due swap requests when calculating events (#2718)
This commit is contained in:
parent
8db1ea5235
commit
2bc5c28777
3 changed files with 12 additions and 0 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Reference in a new issue