diff --git a/CHANGELOG.md b/CHANGELOG.md index d9311a63..380561f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Prevent additional polling on Incidents if the previous request didn't complete ([#3205](https://github.com/grafana/oncall/pull/3205)) - Order results from `GET /teams` internal API endpoint by ascending name by @joeyorlando ([#3220](https://github.com/grafana/oncall/pull/3220)) +- Order alert groups internal API endpoint by descending started_at by @mderynck ([#3240](https://github.com/grafana/oncall/pull/3240)) ### Fixed diff --git a/engine/apps/api/views/alert_group.py b/engine/apps/api/views/alert_group.py index 97ef641e..f1db153a 100644 --- a/engine/apps/api/views/alert_group.py +++ b/engine/apps/api/views/alert_group.py @@ -423,7 +423,7 @@ class AlertGroupView( # enrich alert groups with select_related and prefetch_related alert_group_pks = [alert_group.pk for alert_group in alert_groups] - queryset = AlertGroup.objects.filter(pk__in=alert_group_pks).order_by("-pk") + queryset = AlertGroup.objects.filter(pk__in=alert_group_pks).order_by("-started_at") queryset = self.get_serializer_class().setup_eager_loading(queryset) alert_groups = list(queryset)