Optimize alertgroups endpoint (#1186)
# What this PR does ## Which issue(s) this PR fixes ## Checklist - [ ] Tests updated - [ ] Documentation added - [ ] `CHANGELOG.md` updated
This commit is contained in:
parent
5ef8b8c345
commit
83b1f069d0
2 changed files with 8 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ COPY ./ ./
|
|||
|
||||
# Collect static files and create an SQLite database
|
||||
RUN mkdir -p /var/lib/oncall
|
||||
RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db SECRET_KEY="ThEmUsTSecretKEYforBUILDstage123" python manage.py collectstatic --no-input
|
||||
RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db SECRET_KEY="ThEmUsTSecretKEYforBUILDstage123" SILK_PROFILER_ENABLED="True" python manage.py collectstatic --no-input
|
||||
RUN chown -R 1000:2000 /var/lib/oncall
|
||||
|
||||
FROM base AS dev
|
||||
|
|
|
|||
|
|
@ -206,8 +206,14 @@ class AlertGroupView(
|
|||
|
||||
def get_queryset(self):
|
||||
# no select_related or prefetch_related is used at this point, it will be done on paginate_queryset.
|
||||
alert_receive_channels_ids = list(
|
||||
AlertReceiveChannel.objects.filter(
|
||||
organization_id=self.request.auth.organization.id,
|
||||
team_id=self.request.user.current_team,
|
||||
).values_list("id", flat=True)
|
||||
)
|
||||
queryset = AlertGroup.unarchived_objects.filter(
|
||||
channel__organization=self.request.auth.organization, channel__team=self.request.user.current_team
|
||||
channel_id__in=alert_receive_channels_ids,
|
||||
).only("id")
|
||||
|
||||
return queryset
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue