oncall-engine/engine/apps
Joey Orlando 52ff041066
Optimize duplicate queries occurring in AlertGroupFilter (#1809)
# What this PR does

In `AlertGroupFilter` we currently have 11 duplicate queries which add
~1-2secs of unecessary request latency to `GET
/api/internal/v1/alertgroups` calls.
![Screenshot 2023-04-20 at 17 57
49](https://user-images.githubusercontent.com/9406895/233589341-de5e53ca-f10b-4038-ad68-a857d1643bf2.png)



The queries originate from the `queryset` callable arguments on several
of the fields of the `AlertGroupFilter` class. These callables basically
filter down their respective querysets to include only objects that
belong to the currently authenticated user's organization.

The duplicate queries are
- 2 queries to fetch integrations
- 2 queries to fetch escalation chains
- 10 queries to fetch users

At the moment, this PR is still a draft and doesn't work as intended.
It's based off of [a suggestion from this
discussion](https://github.com/carltongibson/django-filter/discussions/1572#discussioncomment-5676042)
in the `django-filter` repo. See [this DjangoCon
talk](https://youtu.be/e52S1SjuUeM?t=841) for more context.

---------

Co-authored-by: Ildar Iskhakov <Ildar.iskhakov@grafana.com>
2023-04-26 06:16:29 +00:00
..
alerts Add 2, 3 and 6 hours silence options (#1822) 2023-04-26 02:22:18 +00:00
api Optimize duplicate queries occurring in AlertGroupFilter (#1809) 2023-04-26 06:16:29 +00:00
api_for_grafana_incident Include alert details in Grafana Incident alert-group endpoint (#1280) 2023-02-03 13:43:21 +00:00
auth_token Change Organization Deleted/Moved Precedence (#1402) 2023-02-24 11:45:21 +00:00
base Fix documentation links (#1766) 2023-04-19 10:12:16 +01:00
email Inbound email integration (#837) 2023-03-16 13:59:21 +08:00
grafana_plugin Check stack cluster for insight_logs (#1469) 2023-03-09 06:30:54 +00:00
heartbeat Add database migrations linter (#1020) 2023-02-06 16:01:37 +08:00
integrations Limit number of alertmanager alerts in alert group to autoresolve (#1779) 2023-04-24 05:38:21 +00:00
mobile_app Update apns payload with corrected critical field (#1646) 2023-03-28 10:57:40 +00:00
oss_installation Add database migrations linter (#1020) 2023-02-06 16:01:37 +08:00
public_api Update shift API to use a default for interval when missing (#1810) 2023-04-21 19:13:09 +00:00
schedules Enable final schedule exports (#1808) 2023-04-25 15:40:27 +00:00
slack Fix insight_logs exceptions (#1757) 2023-04-17 07:16:18 +00:00
social_auth Fix insight_logs exceptions (#1757) 2023-04-17 07:16:18 +00:00
telegram Fix insight_logs exceptions (#1757) 2023-04-17 07:16:18 +00:00
twilioapp Add database migrations linter (#1020) 2023-02-06 16:01:37 +08:00
user_management Fix insight_logs exceptions (#1757) 2023-04-17 07:16:18 +00:00
webhooks Add is_legacy column to handle webhook migration (#1813) 2023-04-25 11:22:56 -03:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00