Skip to content
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

Merged
merged 5 commits into from
Oct 4, 2023

Conversation

matiasb
Copy link
Contributor

@matiasb matiasb commented Oct 3, 2023

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.

@matiasb matiasb added pr:no changelog pr:no public docs Added to a PR that does not require public documentation updates labels Oct 3, 2023
@matiasb matiasb force-pushed the matiasb/filter-events-shift-info branch from 343fa17 to cf78b29 Compare October 4, 2023 14:19
@matiasb matiasb marked this pull request as ready for review October 4, 2023 14:27
@matiasb matiasb requested a review from a team October 4, 2023 14:27
Copy link
Member

@vstpme vstpme left a 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()
Copy link
Member

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)

Copy link
Contributor Author

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 👍

@matiasb matiasb added this pull request to the merge queue Oct 4, 2023
Merged via the queue into dev with commit abc0f17 Oct 4, 2023
@matiasb matiasb deleted the matiasb/filter-events-shift-info branch October 4, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants