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

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..1055b67a7aac035e7852dfd31b2dae985d71a452 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.
@@ -90,8 +92,13 @@ def CreateStoppageAlert(test, row):
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
chrisphan 2015/11/06 18:06:42 Does this need to always return an entity?
qyearsley 2015/11/06 18:11:08 Nope, as is in this CL, CreateStoppageAlert decide
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