diff --git a/engine/apps/schedules/constants.py b/engine/apps/schedules/constants.py index 719aa0b2..a2ec8adc 100644 --- a/engine/apps/schedules/constants.py +++ b/engine/apps/schedules/constants.py @@ -9,6 +9,6 @@ ICAL_ATTENDEE = "ATTENDEE" ICAL_UID = "UID" ICAL_RRULE = "RRULE" ICAL_UNTIL = "UNTIL" -RE_PRIORITY = re.compile(r"^\[L(\d)\]") +RE_PRIORITY = re.compile(r"^\[L(\d+)\]") RE_EVENT_UID_V1 = re.compile(r"amixr-([\w\d-]+)-U(\d+)-E(\d+)-S(\d+)") RE_EVENT_UID_V2 = re.compile(r"oncall-([\w\d-]+)-PK([\w\d]+)-U(\d+)-E(\d+)-S(\d+)") diff --git a/engine/apps/schedules/ical_utils.py b/engine/apps/schedules/ical_utils.py index 12fb5bd1..620e4450 100644 --- a/engine/apps/schedules/ical_utils.py +++ b/engine/apps/schedules/ical_utils.py @@ -190,18 +190,19 @@ def get_shifts_dict(calendar, calendar_type, schedule, datetime_start, datetime_ ) else: start, end = ical_events.get_start_and_end_with_respect_to_event_type(event) - result_datetime.append( - { - "start": start.astimezone(pytz.UTC), - "end": end.astimezone(pytz.UTC), - "users": users, - "missing_users": missing_users, - "priority": priority, - "source": source, - "calendar_type": calendar_type, - "shift_pk": pk, - } - ) + if start < end: + result_datetime.append( + { + "start": start.astimezone(pytz.UTC), + "end": end.astimezone(pytz.UTC), + "users": users, + "missing_users": missing_users, + "priority": priority, + "source": source, + "calendar_type": calendar_type, + "shift_pk": pk, + } + ) return result_datetime, result_date