Show 100000+ in stats when there are more than 100000 alert groups in the result (#1901)
# What this PR does ## Which issue(s) this PR fixes ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
e265bade4f
commit
065cc9343a
2 changed files with 6 additions and 12 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Change permissions used during setup to better represent actions being taken by @mderynck ([#2242](https://github.com/grafana/oncall/pull/2242))
|
- 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)
|
## v1.3.1 (2023-06-26)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,20 +400,13 @@ class AlertGroupView(
|
||||||
|
|
||||||
@action(detail=False)
|
@action(detail=False)
|
||||||
def stats(self, *args, **kwargs):
|
def stats(self, *args, **kwargs):
|
||||||
alert_groups = self.filter_queryset(self.get_queryset())
|
MAX_COUNT = 100001
|
||||||
# Only count field is used, other fields left just in case for the backward compatibility
|
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(
|
return Response(
|
||||||
{
|
{
|
||||||
"count": alert_groups.filter().count(),
|
"count": 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,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue