oncall-engine/engine/apps/schedules/constants.py
Yulya Artyukhina 6a5267b847
Optimize GET /schedules and /current_user_events internal api endpoints (#4169)
# What this PR does
Speed up `GET /schedules` and `GET /current_user_events` internal api
endpoints by reducing number of calls to database

## Which issue(s) this PR closes
Related to https://github.com/grafana/oncall-private/issues/1552

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-04-11 14:46:51 +00:00

33 lines
1,020 B
Python

import re
ICAL_DATETIME_START = "DTSTART"
ICAL_DATETIME_END = "DTEND"
ICAL_DATETIME_STAMP = "DTSTAMP"
ICAL_SUMMARY = "SUMMARY"
ICAL_DESCRIPTION = "DESCRIPTION"
ICAL_ATTENDEE = "ATTENDEE"
ICAL_UID = "UID"
ICAL_SEQUENCE = "SEQUENCE"
ICAL_RECURRENCE_ID = "RECURRENCE-ID"
ICAL_RRULE = "RRULE"
ICAL_UNTIL = "UNTIL"
ICAL_LAST_MODIFIED = "LAST-MODIFIED"
ICAL_LOCATION = "LOCATION"
ICAL_PRIORITY = "PRIORITY"
ICAL_STATUS = "STATUS"
ICAL_STATUS_CANCELLED = "CANCELLED"
ICAL_COMPONENT_VEVENT = "VEVENT"
RE_PRIORITY = re.compile(r"^\[L(\d+)\]")
RE_EVENT_UID_EXPORT = re.compile(r"([\w\d]+)-(\d+)-([\w\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+)")
CALENDAR_TYPE_FINAL = "final"
EXPORT_WINDOW_DAYS_AFTER = 180
EXPORT_WINDOW_DAYS_BEFORE = 15
SCHEDULE_ONCALL_CACHE_KEY_PREFIX = "schedule_oncall_users_"
SCHEDULE_ONCALL_CACHE_TTL = 15 * 60 # 15 minutes in seconds
PREFETCHED_SHIFT_SWAPS = "prefetched_shift_swaps"