-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update schedule filter events endpoint to return additional shift info #3110
Conversation
343fa17
to
cf78b29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor question
@@ -70,6 +70,10 @@ def get_shift_end(self, obj): | |||
def to_representation(self, instance): | |||
ret = super().to_representation(instance) | |||
ret["week_start"] = CustomOnCallShift.ICAL_WEEKDAY_MAP[instance.week_start] | |||
if ret["schedule"] is None: | |||
# for terraform based schedules, related schedule comes from M2M field | |||
related_schedule = instance.schedules.last() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking: wouldn't this produce an SQL query for each on-call shift in the queryset? (N+1 issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, let me set a prefetch_related for this, pushing an update 👍
Related to https://github.com/grafana/oncall-private/issues/2191
This will also allow plugin to get shift name and type from the filter_events API, without needing to get details for each involved shift in the user's on-call summary timeline.