Skip to content

Commit

Permalink
Update schedule events internal API to return default priority level (#…
Browse files Browse the repository at this point in the history
…4697)

No need to change 0 to `None` in priority level when returning schedule
events (related to this
[thread](https://raintank-corp.slack.com/archives/C0229FD3CE9/p1721239227358309?thread_ts=1721148066.857589&cid=C0229FD3CE9))
  • Loading branch information
matiasb authored Jul 18, 2024
1 parent 7777a60 commit 1c33964
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion engine/apps/api/tests/test_oncall_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ def test_on_call_shift_preview_without_users(
"is_override": False,
"is_empty": True,
"is_gap": False,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"source": "web",
Expand Down
4 changes: 2 additions & 2 deletions engine/apps/api/tests/test_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ def test_filter_events_overrides(
}
],
"missing_users": [],
"priority_level": None,
"priority_level": 0,
"source": "api",
"calendar_type": OnCallSchedule.OVERRIDES,
"is_empty": False,
Expand Down Expand Up @@ -1307,7 +1307,7 @@ def test_filter_events_final_schedule(
"end": start_date + timezone.timedelta(hours=start + duration),
"is_gap": is_gap,
"is_override": is_override,
"priority_level": priority,
"priority_level": priority or 0,
"start": start_date + timezone.timedelta(hours=start),
"user": user,
}
Expand Down
2 changes: 1 addition & 1 deletion engine/apps/schedules/models/on_call_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def filter_events(
for user in shift["users"]
],
"missing_users": shift["missing_users"],
"priority_level": shift["priority"] if shift["priority"] != 0 else None,
"priority_level": shift["priority"] or 0,
"source": shift["source"],
"calendar_type": shift["calendar_type"],
"is_empty": len(shift["users"]) == 0 and not is_gap,
Expand Down
22 changes: 11 additions & 11 deletions engine/apps/schedules/tests/test_on_call_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_filter_events(make_organization, make_user_for_organization, make_sched
"is_override": True,
"is_empty": False,
"is_gap": False,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [
{
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_filter_events_include_gaps(make_organization, make_user_for_organizatio
"is_override": False,
"is_empty": False,
"is_gap": True,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"shift": {"pk": None},
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_filter_events_include_gaps(make_organization, make_user_for_organizatio
"is_override": False,
"is_empty": False,
"is_gap": True,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"shift": {"pk": None},
Expand Down Expand Up @@ -263,7 +263,7 @@ def test_filter_events_include_shift_info(
"is_override": False,
"is_empty": False,
"is_gap": True,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"shift": {"pk": None},
Expand Down Expand Up @@ -302,7 +302,7 @@ def test_filter_events_include_shift_info(
"is_override": False,
"is_empty": False,
"is_gap": True,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"shift": {"pk": None},
Expand Down Expand Up @@ -512,7 +512,7 @@ def test_final_schedule_events(
"end": start_date + timezone.timedelta(hours=start + duration),
"is_gap": is_gap,
"is_override": is_override,
"priority_level": priority,
"priority_level": priority or 0,
"start": start_date + timezone.timedelta(hours=start),
"user": user,
"shift": (
Expand Down Expand Up @@ -599,7 +599,7 @@ def test_final_schedule_override_no_priority_shift(
"calendar_type": 1 if is_override else 0,
"end": start_date + timezone.timedelta(hours=start + duration),
"is_override": is_override,
"priority_level": priority,
"priority_level": priority or 0,
"start": start_date + timezone.timedelta(hours=start, milliseconds=1 if start == 0 else 0),
"user": user,
}
Expand Down Expand Up @@ -679,7 +679,7 @@ def test_final_schedule_override_split(
"calendar_type": 1 if is_override else 0,
"end": start_date + timezone.timedelta(hours=start + duration),
"is_override": is_override,
"priority_level": priority,
"priority_level": priority or 0,
"start": start_date + timezone.timedelta(hours=start, milliseconds=1 if start == 0 else 0),
"user": user,
}
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def test_preview_shift_no_user(make_organization, make_user_for_organization, ma
"is_override": False,
"is_empty": True,
"is_gap": False,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [],
"shift": {"pk": new_shift.public_primary_key},
Expand Down Expand Up @@ -1130,7 +1130,7 @@ def test_preview_override_shift(make_organization, make_user_for_organization, m
"is_override": True,
"is_empty": False,
"is_gap": False,
"priority_level": None,
"priority_level": 0,
"missing_users": [],
"users": [
{
Expand All @@ -1156,7 +1156,7 @@ def test_preview_override_shift(make_organization, make_user_for_organization, m
expected_events = [
{
"end": start_date + timezone.timedelta(hours=start + duration),
"priority_level": priority,
"priority_level": priority or 0,
"start": start_date + timezone.timedelta(hours=start, milliseconds=1 if start == 0 else 0),
"user": user,
"is_override": is_override,
Expand Down

0 comments on commit 1c33964

Please sign in to comment.