Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: dashboard/dashboard/models/stoppage_alert.py

Issue 1424393003: Stop creating stoppage alerts once a group has reached a certain size. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dashboard/dashboard/models/stoppage_alert_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/models/stoppage_alert.py
diff --git a/dashboard/dashboard/models/stoppage_alert.py b/dashboard/dashboard/models/stoppage_alert.py
index 19240907d88bd38a396da7a10879580092c118e7..68476efbbcceab2f61d89eba5f46f8bf06e27bbd 100644
--- a/dashboard/dashboard/models/stoppage_alert.py
+++ b/dashboard/dashboard/models/stoppage_alert.py
@@ -12,6 +12,8 @@ from dashboard import utils
from dashboard.models import alert
from dashboard.models import alert_group
+_MAX_GROUP_SIZE = 20
+
class StoppageAlert(alert.Alert):
"""A stoppage alert is an alert for a Test no longer receiving new points.
@@ -83,15 +85,21 @@ def CreateStoppageAlert(test, row):
row: A Row entity; the last Row that was put before the stoppage.
Returns:
- A new StoppageAlert entity (although this entity has not yet been put.
+ A new StoppageAlert entity which has not been put, or None,
+ if we don't want to create a new StoppageAlert.
"""
new_alert = StoppageAlert(
parent=ndb.Key('StoppageAlertParent', test.test_path),
id=row.revision,
internal_only=test.internal_only,
sheriff=test.sheriff)
+ alert_group.GroupAlerts([new_alert], test.suite_name, 'StoppageAlert')
+ grouped_alert_keys = StoppageAlert.query(
+ StoppageAlert.group == new_alert.group).fetch(keys_only=True)
+ if len(grouped_alert_keys) >= _MAX_GROUP_SIZE:
+ # Too many stoppage alerts in this group; we don't want to put any more.
+ return None
test.stoppage_alert = new_alert.key
test.put()
- alert_group.GroupAlerts([new_alert], test.suite_name, 'StoppageAlert')
return new_alert
« no previous file with comments | « no previous file | dashboard/dashboard/models/stoppage_alert_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698