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

Unified Diff: dashboard/dashboard/edit_anomalies.py

Issue 2650683007: Dashboard - Remove pre-hook logic from alert.py. (Closed)
Patch Set: Fix race in delete. Created 3 years, 10 months 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 | « dashboard/dashboard/associate_alerts.py ('k') | dashboard/dashboard/file_bug.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/edit_anomalies.py
diff --git a/dashboard/dashboard/edit_anomalies.py b/dashboard/dashboard/edit_anomalies.py
index ae0c86ef866bc0e045c707061902678ca0fd0b54..34780ebafdc18ba89ee0dc28904a52ca7f6e5274 100644
--- a/dashboard/dashboard/edit_anomalies.py
+++ b/dashboard/dashboard/edit_anomalies.py
@@ -12,6 +12,7 @@ from google.appengine.ext import ndb
from dashboard.common import request_handler
from dashboard.common import utils
from dashboard.common import xsrf
+from dashboard.models import alert_group
class EditAnomaliesHandler(request_handler.RequestHandler):
@@ -56,13 +57,15 @@ class EditAnomaliesHandler(request_handler.RequestHandler):
bug_id = self.request.get('bug_id')
new_start_revision = self.request.get('new_start_revision')
new_end_revision = self.request.get('new_end_revision')
+ result = None
if bug_id:
- self.ChangeBugId(alert_entities, bug_id)
+ result = self.ChangeBugId(alert_entities, bug_id)
elif new_start_revision and new_end_revision:
- self.NudgeAnomalies(alert_entities, new_start_revision, new_end_revision)
+ result = self.NudgeAnomalies(
+ alert_entities, new_start_revision, new_end_revision)
else:
- self.response.out.write(
- json.dumps({'error': 'No bug ID or new revision specified.'}))
+ result = {'error': 'No bug ID or new revision specified.'}
+ self.response.out.write(json.dumps(result))
def ChangeBugId(self, alert_entities, bug_id):
"""Changes or resets the bug ID of all given alerts."""
@@ -73,14 +76,11 @@ class EditAnomaliesHandler(request_handler.RequestHandler):
try:
bug_id = int(bug_id)
except ValueError:
- self.response.out.write(json.dumps({
- 'error': 'Invalid bug ID %s' % str(bug_id)}))
- return
- for a in alert_entities:
- a.bug_id = bug_id
+ return {'error': 'Invalid bug ID %s' % str(bug_id)}
- ndb.put_multi(alert_entities)
- self.response.out.write(json.dumps({'bug_id': bug_id}))
+ alert_group.ModifyAlertsAndAssociatedGroups(alert_entities, bug_id=bug_id)
+
+ return {'bug_id': bug_id}
def NudgeAnomalies(self, anomaly_entities, start, end):
# Change the revision range if a new revision range is specified and valid.
@@ -88,12 +88,9 @@ class EditAnomaliesHandler(request_handler.RequestHandler):
start = int(start)
end = int(end)
except ValueError:
- self.response.out.write(
- json.dumps({'error': 'Invalid revisions %s, %s' % (start, end)}))
- return
- for a in anomaly_entities:
- a.start_revision = start
- a.end_revision = end
+ return {'error': 'Invalid revisions %s, %s' % (start, end)}
+
+ alert_group.ModifyAlertsAndAssociatedGroups(
+ anomaly_entities, start_revision=start, end_revision=end)
- ndb.put_multi(anomaly_entities)
- self.response.out.write(json.dumps({'success': 'Alerts nudged.'}))
+ return {'success': 'Alerts nudged.'}
« no previous file with comments | « dashboard/dashboard/associate_alerts.py ('k') | dashboard/dashboard/file_bug.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698