oncall-engine/engine/apps/api/views
Ildar Iskhakov b90fe433c9
Optimize alertgroups endpoint (#1189)
# What this PR does

Changing query to retrieve alert group in two completely different
queries instead of one with `join`

new queries
```
SELECT alerts_alertreceivechannel.id
FROM alerts_alertreceivechannel
WHERE (alerts_alertreceivechannel.deleted_at IS NULL
       AND alerts_alertreceivechannel.organization_id = 8
       AND alerts_alertreceivechannel.team_id IS NULL)


SELECT `alerts_alertgroup`.`id`
FROM `alerts_alertgroup`
WHERE (`alerts_alertgroup`.`channel_id` IN (2,33,34,35,36,40,52,59,61,62,63,70,76,89,93,94,03,08,09,10,12,13,16,18,20,22,23,24,26,27,28,30,31,33,34,35,36,40,41,42,43,45,48,53,56,57,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,88,89,91,93,23,27,29,31,32,33,55,56,57,58,65,69,72,75,81,13,17,20,22,33,34,38,39,41,44,45,46,51,52,55,56,58,59,60,63,68,70,71)
       AND NOT `alerts_alertgroup`.`is_archived`
       AND NOT `alerts_alertgroup`.`is_archived`
       AND `alerts_alertgroup`.`root_alert_group_id` IS NULL
       AND ((NOT `alerts_alertgroup`.`silenced`
             AND NOT `alerts_alertgroup`.`acknowledged`
             AND NOT `alerts_alertgroup`.`resolved`)
            OR (`alerts_alertgroup`.`acknowledged`
                AND NOT `alerts_alertgroup`.`resolved`))
       AND NOT `alerts_alertgroup`.`is_archived`)
ORDER BY `alerts_alertgroup`.`id` DESC
LIMIT 26
```

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2023-01-22 00:53:11 +08:00
..
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
alert_group.py Optimize alertgroups endpoint (#1189) 2023-01-22 00:53:11 +08:00
alert_receive_channel.py Hide direct paging integrations (#1162) 2023-01-20 13:29:57 +00:00
alert_receive_channel_template.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
alerts.py Add alert detail view (#385) 2022-08-19 14:03:07 +05:00
auth.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
channel_filter.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
custom_button.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
escalation_chain.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
escalation_policy.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
features.py Mobile app messaging backend (#874) 2022-11-23 15:56:43 +00:00
gitops.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
integration_heartbeat.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
live_setting.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
maintenance.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
on_call_shifts.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
organization.py Introduce org uuid (#947) 2022-12-06 22:42:58 +08:00
paging.py Add an ability to use an escalation chain for direct paging (#1161) 2023-01-19 18:51:57 +00:00
preview_template_options.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
public_api_tokens.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
resolution_note.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
route_regex_debugger.py Optimize alert group list view (#299) 2022-07-27 14:14:59 +03:00
schedule.py Update schedules query not to defer ical fields used for on-call check (#1114) 2023-01-09 14:10:23 -03:00
slack_channel.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
slack_team_settings.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
subscription.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
team.py Mobile app messaging backend (#874) 2022-11-23 15:56:43 +00:00
telegram_channels.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
test_insight_logs.py Fix propagation for the insight logger 2022-07-25 12:59:12 +04:00
user.py Draft initial logic for user/schedule paging (#1098) 2023-01-17 12:19:08 -03:00
user_group.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
user_notification_policy.py Allow messaging backends to be enabled/disabled per organization (#1151) 2023-01-18 15:52:25 +00:00