Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show 100000+ in stats when there are more than 100000 alert groups in the result #1901

Merged
merged 6 commits into from
Jun 27, 2023

Conversation

iskhakov
Copy link
Contributor

@iskhakov iskhakov commented May 9, 2023

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)

@iskhakov iskhakov requested a review from a team May 9, 2023 02:34
@iskhakov iskhakov marked this pull request as draft May 9, 2023 02:45
@@ -398,20 +398,14 @@ 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 = 1001
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: define this number

# Only count field is used, other fields left just in case for the backward compatibility
MAX_COUNT = 1001
alert_groups = self.filter_queryset(self.get_queryset())[:MAX_COUNT]
count = alert_groups.count()
Copy link
Contributor Author

@iskhakov iskhakov May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check if we need to use len() here

Comment on lines -405 to -416
"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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiice

MAX_COUNT = 1001
alert_groups = self.filter_queryset(self.get_queryset())[:MAX_COUNT]
count = alert_groups.count()
print(count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print statement

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the Stale label Jun 14, 2023
@joeyorlando joeyorlando added pr:stale Added to a PR that has been deemed "stale". Managed by the actions/stale GitHub Action and removed Stale labels Jun 21, 2023
@github-actions github-actions bot removed the pr:stale Added to a PR that has been deemed "stale". Managed by the actions/stale GitHub Action label Jun 24, 2023
@iskhakov iskhakov added the pr:no public docs Added to a PR that does not require public documentation updates label Jun 27, 2023
@iskhakov iskhakov changed the title Add limit to stats count, e.g. 1000+ resolved alerts Show 100000+ in stats where there are more than 100000 alert groups in the result Jun 27, 2023
@iskhakov iskhakov changed the title Show 100000+ in stats where there are more than 100000 alert groups in the result Show 100000+ in stats when there are more than 100000 alert groups in the result Jun 27, 2023
@iskhakov iskhakov marked this pull request as ready for review June 27, 2023 02:53
@iskhakov iskhakov enabled auto-merge June 27, 2023 02:53
@iskhakov iskhakov added this pull request to the merge queue Jun 27, 2023
Merged via the queue into dev with commit 065cc93 Jun 27, 2023
@iskhakov iskhakov deleted the iskhakov/max-count-stats branch June 27, 2023 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants