diff --git a/CHANGELOG.md b/CHANGELOG.md index e254d25a..88143ff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Change permissions used during setup to better represent actions being taken by @mderynck ([#2242](https://github.com/grafana/oncall/pull/2242)) +- Display 100000+ in stats when there are more than 100000 alert groups in the result ([#1901](https://github.com/grafana/oncall/pull/1901)) ## v1.3.1 (2023-06-26) diff --git a/engine/apps/api/views/alert_group.py b/engine/apps/api/views/alert_group.py index 1e9f4bef..164c5919 100644 --- a/engine/apps/api/views/alert_group.py +++ b/engine/apps/api/views/alert_group.py @@ -400,20 +400,13 @@ class AlertGroupView( @action(detail=False) def stats(self, *args, **kwargs): - alert_groups = self.filter_queryset(self.get_queryset()) - # Only count field is used, other fields left just in case for the backward compatibility + MAX_COUNT = 100001 + alert_groups = self.filter_queryset(self.get_queryset())[:MAX_COUNT] + count = alert_groups.count() + count = f"{MAX_COUNT-1}+" if count == MAX_COUNT else str(count) return Response( { - "count": alert_groups.filter().count(), - "count_previous_same_period": 0, - "alert_group_rate_to_previous_same_period": 1, - "count_escalations": 0, - "count_escalations_previous_same_period": 0, - "escalation_rate_to_previous_same_period": 1, - "average_response_time": None, - "average_response_time_to_previous_same_period": None, - "average_response_time_rate_to_previous_same_period": 0, - "prev_period_in_days": 1, + "count": count, } )