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

Unified Diff: dashboard/dashboard/edit_anomalies.py

Issue 2670003006: Revert of Dashboard - Remove pre-hook logic from alert.py. (Closed)
Patch Set: 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 34780ebafdc18ba89ee0dc28904a52ca7f6e5274..ae0c86ef866bc0e045c707061902678ca0fd0b54 100644
--- a/dashboard/dashboard/edit_anomalies.py
+++ b/dashboard/dashboard/edit_anomalies.py
@@ -12,7 +12,6 @@
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):
@@ -57,15 +56,13 @@
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:
- result = self.ChangeBugId(alert_entities, bug_id)
+ self.ChangeBugId(alert_entities, bug_id)
elif new_start_revision and new_end_revision:
- result = self.NudgeAnomalies(
- alert_entities, new_start_revision, new_end_revision)
+ self.NudgeAnomalies(alert_entities, new_start_revision, new_end_revision)
else:
- result = {'error': 'No bug ID or new revision specified.'}
- self.response.out.write(json.dumps(result))
+ self.response.out.write(
+ json.dumps({'error': 'No bug ID or new revision specified.'}))
def ChangeBugId(self, alert_entities, bug_id):
"""Changes or resets the bug ID of all given alerts."""
@@ -76,11 +73,14 @@
try:
bug_id = int(bug_id)
except ValueError:
- return {'error': 'Invalid bug ID %s' % str(bug_id)}
+ 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
- alert_group.ModifyAlertsAndAssociatedGroups(alert_entities, bug_id=bug_id)
-
- return {'bug_id': bug_id}
+ ndb.put_multi(alert_entities)
+ self.response.out.write(json.dumps({'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,9 +88,12 @@
start = int(start)
end = int(end)
except ValueError:
- return {'error': 'Invalid revisions %s, %s' % (start, end)}
+ 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
- alert_group.ModifyAlertsAndAssociatedGroups(
- anomaly_entities, start_revision=start, end_revision=end)
-
- return {'success': 'Alerts nudged.'}
+ ndb.put_multi(anomaly_entities)
+ self.response.out.write(json.dumps({'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