Fix swap requests event filter limits (#2716)
This commit is contained in:
parent
26921fc67a
commit
289573effe
3 changed files with 14 additions and 6 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Fix schedule final_events datetime filtering when splitting override ([#2715](https://github.com/grafana/oncall/pull/2715))
|
||||
- Fix swap requests event filter limits in schedule events ([#2716](https://github.com/grafana/oncall/pull/2716))
|
||||
|
||||
## v1.3.21 (2023-08-01)
|
||||
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ class OnCallSchedule(PolymorphicModel):
|
|||
while i < len(events):
|
||||
event = events.pop(i)
|
||||
|
||||
if event["start"] > swap.swap_end or event["end"] < swap.swap_start:
|
||||
if event["start"] >= swap.swap_end or event["end"] <= swap.swap_start:
|
||||
# event outside the swap period, keep as it is and continue
|
||||
i = _insert_event(i, event)
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -2188,18 +2188,25 @@ def test_swap_request_whole_shift(
|
|||
swap_request = make_shift_swap_request(
|
||||
schedule,
|
||||
user,
|
||||
swap_start=tomorrow + timezone.timedelta(hours=12),
|
||||
swap_end=tomorrow + timezone.timedelta(hours=15),
|
||||
# swap request starting right after shift ends
|
||||
swap_start=tomorrow + timezone.timedelta(hours=15),
|
||||
# swap request ending right before shift starts
|
||||
swap_end=tomorrow + timezone.timedelta(days=2, hours=12),
|
||||
)
|
||||
if swap_taken:
|
||||
swap_request.take(other_user)
|
||||
|
||||
events = schedule.filter_events(today, today + timezone.timedelta(days=2))
|
||||
events = schedule.filter_events(tomorrow, tomorrow + timezone.timedelta(days=2))
|
||||
|
||||
tomorrow_start = start + timezone.timedelta(days=1)
|
||||
expected = [
|
||||
# start, end, swap requested
|
||||
(start, start + duration, False), # today shift unchanged
|
||||
(start + timezone.timedelta(days=1), start + timezone.timedelta(days=1, hours=3), True), # no splits
|
||||
(tomorrow_start, tomorrow_start + duration, False), # today shift unchanged
|
||||
(
|
||||
tomorrow_start + timezone.timedelta(days=1),
|
||||
tomorrow_start + timezone.timedelta(days=1, hours=3),
|
||||
True,
|
||||
), # no splits
|
||||
]
|
||||
returned = [(e["start"], e["end"], bool(e["users"][0].get("swap_request", False))) for e in events]
|
||||
assert returned == expected
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue