Modify alert group list index (#3502)
# What this PR does Modifies the database index used by the alert group list page to accommodate ordering by [`-started_at`](https://github.com/grafana/oncall/pull/3502/files#diff-68d8b0b2e9b7affe54e5950215e69df4afcc6f7f5dd7eeceb810afda0dd5e1d3R85) ## Which issue(s) this PR fixes Related to https://github.com/grafana/support-escalations/issues/8567 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
3e1d069859
commit
44484b56f1
4 changed files with 29 additions and 5 deletions
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 4.2.7 on 2023-12-06 13:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('alerts', '0042_alertgroup_received_at'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='alertgroup',
|
||||
index=models.Index(fields=['channel_id', 'resolved', 'acknowledged', 'silenced', 'root_alert_group_id', 'started_at'], name='alert_group_list_index'),
|
||||
),
|
||||
migrations.RemoveIndex(
|
||||
model_name='alertgroup',
|
||||
name='alerts_aler_channel_81aeec_idx',
|
||||
),
|
||||
]
|
||||
|
|
@ -457,7 +457,10 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models.
|
|||
"is_open_for_grouping",
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["channel_id", "resolved", "acknowledged", "silenced", "root_alert_group_id"]),
|
||||
models.Index(
|
||||
fields=["channel_id", "resolved", "acknowledged", "silenced", "root_alert_group_id", "started_at"],
|
||||
name="alert_group_list_index",
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ from apps.user_management.models import Team, User
|
|||
from common.api_helpers.exceptions import BadRequest
|
||||
from common.api_helpers.filters import NO_TEAM_VALUE, DateRangeFilterMixin, ModelFieldFilterMixin
|
||||
from common.api_helpers.mixins import PreviewTemplateMixin, PublicPrimaryKeyMixin, TeamFilteringMixin
|
||||
from common.api_helpers.paginators import TwentyFiveCursorPaginator
|
||||
from common.api_helpers.paginators import AlertGroupCursorPaginator
|
||||
|
||||
|
||||
def get_integration_queryset(request):
|
||||
|
|
@ -309,7 +309,7 @@ class AlertGroupView(
|
|||
|
||||
serializer_class = AlertGroupSerializer
|
||||
|
||||
pagination_class = TwentyFiveCursorPaginator
|
||||
pagination_class = AlertGroupCursorPaginator
|
||||
|
||||
filter_backends = [SearchFilter, AlertGroupFilterBackend]
|
||||
# search_fields = ["=public_primary_key", "=inside_organization_number", "web_title_cache"]
|
||||
|
|
|
|||
|
|
@ -80,6 +80,6 @@ class FifteenPageSizePaginator(PathPrefixedPagePagination):
|
|||
page_size = 15
|
||||
|
||||
|
||||
class TwentyFiveCursorPaginator(PathPrefixedCursorPagination):
|
||||
class AlertGroupCursorPaginator(PathPrefixedCursorPagination):
|
||||
page_size = 25
|
||||
ordering = "-started_at"
|
||||
ordering = "-started_at" # ordering by "-started_at", so it uses the right index (see AlertGroup.Meta.indexes)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue