Enable final schedule exports (#1808)

Update iCal schedule and personal exports to use final schedule events.
This commit is contained in:
Matias Bordese 2023-04-25 12:40:27 -03:00 committed by GitHub
parent 20ec6f52bc
commit cdb62f2cf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 15 deletions

View file

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update shift API to use a default interval value (`1`) when a `frequency` is set and no `interval` is given
- Limit number of alertmanager alerts in alert group to autoresolve by 500 ([1779](https://github.com/grafana/oncall/pull/1779))
- Update schedule and personal ical exports to use final shift events
## v1.2.14 (2023-04-19)

View file

@ -652,14 +652,8 @@ def _get_ical_data_final_schedule(schedule: OnCallSchedule) -> str:
def ical_export_from_schedule(schedule: OnCallSchedule) -> bytes:
if _is_final_export_enabled(schedule):
ical_data = _get_ical_data_final_schedule(schedule)
return ical_data.encode()
else:
calendars = schedule.get_icalendars()
ical_obj = create_base_icalendar(schedule.name)
get_events_from_calendars(ical_obj, calendars)
return ical_obj.to_ical()
def user_ical_export(user: User, schedules: list[OnCallSchedule]) -> bytes:
@ -667,13 +661,9 @@ def user_ical_export(user: User, schedules: list[OnCallSchedule]) -> bytes:
ical_obj = create_base_icalendar(schedule_name)
for schedule in schedules:
if _is_final_export_enabled(schedule):
name = schedule.name
ical_data = _get_ical_data_final_schedule(schedule)
calendars = [Calendar.from_ical(ical_data)]
else:
name = None
calendars = schedule.get_icalendars()
get_user_events_from_calendars(ical_obj, calendars, user, name=name)
return ical_obj.to_ical()