Skip to content

Commit

Permalink
Show 100000+ in stats when there are more than 100000 alert groups in…
Browse files Browse the repository at this point in the history
… 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)
  • Loading branch information
iskhakov authored Jun 27, 2023
1 parent e265bad commit 065cc93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 5 additions & 12 deletions engine/apps/api/views/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,13 @@ def enrich(self, alert_groups):

@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,
}
)

Expand Down

0 comments on commit 065cc93

Please sign in to comment.