oncall-engine/engine/apps/api
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
..
permissions optimize GET /schedules internal API endpoint (#1169) 2023-01-25 11:08:09 +01:00
serializers Add is_legacy column to handle webhook migration (#1813) 2023-04-25 11:22:56 -03:00
tests Add is_legacy column to handle webhook migration (#1813) 2023-04-25 11:22:56 -03:00
throttlers Add ratelimit for phone number verification (#1354) 2023-02-21 16:47:52 +08:00
views Optimize duplicate queries occurring in AlertGroupFilter (#1809) 2023-04-26 06:16:29 +00:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
response_renderers.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
urls.py Add initial webhooks internal plugin API (#1524) 2023-03-10 17:00:06 +00:00