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

Side by Side Diff: Tools/GardeningServer/model/ct-failures.html

Issue 526633002: Apply object updates from the network without blowing away object identity or UI attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplify and document updateLeft() using the fact that it returns the resulting object. Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 <!-- 1 <!--
2 Copyright 2014 The Chromium Authors. All rights reserved. 2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be 3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file. 4 found in the LICENSE file.
5 --> 5 -->
6 6
7 <link rel="import" href="../lib/net.html"> 7 <link rel="import" href="../lib/net.html">
8 <link rel="import" href="../lib/update-util.html">
8 <link rel="import" href="ct-builder-revisions.html"> 9 <link rel="import" href="ct-builder-revisions.html">
9 <link rel="import" href="ct-failure.html"> 10 <link rel="import" href="ct-failure.html">
10 <link rel="import" href="ct-failure-group.html"> 11 <link rel="import" href="ct-failure-group.html">
11 <link rel="import" href="ct-commit-list.html"> 12 <link rel="import" href="ct-commit-list.html">
12 13
13 <script> 14 <script>
14 function CTFailures(commitLog) { 15 function CTFailures(commitLog) {
15 this.commitLog = commitLog; 16 this.commitLog = commitLog;
16 this.builderLatestRevisions = null; 17 this.builderLatestRevisions = null;
17 this.failures = null; 18 // Maps a tree id to an array of CTFailureGroups within that tree.
19 this.failures = {};
18 this.lastUpdateDate = null; 20 this.lastUpdateDate = null;
19 21
20 // FIXME: Get this from 22 // FIXME: Get this from
21 // https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/sla ve/gatekeeper_trees.json?format=text. 23 // https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/sla ve/gatekeeper_trees.json?format=text.
22 this._trees = { 24 this._trees = {
23 blink: [ 25 blink: [
24 "https://build.chromium.org/p/chromium.webkit", 26 "https://build.chromium.org/p/chromium.webkit",
25 ], 27 ],
26 chromium: [ 28 chromium: [
27 "https://build.chromium.org/p/chromium", 29 "https://build.chromium.org/p/chromium",
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return -1; 72 return -1;
71 73
72 if (a_list.last() != b_list.last()) 74 if (a_list.last() != b_list.last())
73 return b_list.last() - a_list.last(); 75 return b_list.last() - a_list.last();
74 } 76 }
75 return 0; 77 return 0;
76 }; 78 };
77 79
78 CTFailures.prototype.update = function() { 80 CTFailures.prototype.update = function() {
79 var annotationPromise = CTFailureGroup.fetchAnnotations(); 81 var annotationPromise = CTFailureGroup.fetchAnnotations();
80 net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(data) { 82
81 annotationPromise.then(function(annotations) { 83 return net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(dat a) {
84 return annotationPromise.then(function(annotations) {
82 // FIXME: Don't special-case the blink master. 85 // FIXME: Don't special-case the blink master.
83 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_builder_i nfo['chromium.webkit']); 86 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_builder_i nfo['chromium.webkit']);
84 this.failures = {}; 87 var newFailures = {};
85 this.lastUpdateDate = new Date(data.date * 1000); 88 this.lastUpdateDate = new Date(data.date * 1000);
86 // Update |failures| with the appropriate CTFailureGroup's for each 89 // Update |failures| with the appropriate CTFailureGroup's for each
87 // tree. 90 // tree.
88 data.range_groups.forEach(function(rangeGroup) { 91 data.range_groups.forEach(function(rangeGroup) {
89 this._processFailuresForRangeGroup(rangeGroup, data.alerts, annotations) ; 92 this._processFailuresForRangeGroup(newFailures, rangeGroup, data.alerts, annotations);
90 }.bind(this)); 93 }.bind(this));
91 // Sort failure groups so that newer failures are shown at the top 94 // Sort failure groups so that newer failures are shown at the top
92 // of the UI. 95 // of the UI.
93 Object.keys(this.failures, function (tree, failuresByTree) { 96 Object.keys(newFailures, function (tree, failuresByTree) {
94 this.failures[tree].sort(this._failureByTreeListComparator.bind(this, tr ee)); 97 failuresByTree.sort(this._failureByTreeListComparator.bind(this, tree));
95 }.bind(this)); 98 }.bind(this));
99 this.failures = updateUtil.updateLeft(this.failures, newFailures);
96 }.bind(this)); 100 }.bind(this));
97 }.bind(this)); 101 }.bind(this));
98 }; 102 };
99 103
100 CTFailures.prototype._failureComparator = function(a, b) { 104 CTFailures.prototype._failureComparator = function(a, b) {
101 if (a.step > b.step) 105 if (a.step > b.step)
102 return 1; 106 return 1;
103 if (a.step < b.step) 107 if (a.step < b.step)
104 return -1 108 return -1
105 if (a.testName > b.testName) 109 if (a.testName > b.testName)
106 return 1; 110 return 1;
107 if (a.testName < b.testName) 111 if (a.testName < b.testName)
108 return -1 112 return -1
109 return 0; 113 return 0;
110 }; 114 };
111 115
112 CTFailures.prototype._processFailuresForRangeGroup = function(rangeGroup, alerts , annotations) { 116 CTFailures.prototype._processFailuresForRangeGroup = function(newFailures, range Group, alerts, annotations) {
113 var masterToTree = {}; 117 var masterToTree = {};
114 Object.keys(this._trees, function(tree, masters) { 118 Object.keys(this._trees, function(tree, masters) {
115 masters.forEach(function(master) { 119 masters.forEach(function(master) {
116 masterToTree[master] = tree; 120 masterToTree[master] = tree;
117 }); 121 });
118 }); 122 });
119 123
120 // A rangeGroup may be related to multiple alerts (via |failure_keys|). Catego rize 124 // A rangeGroup may be related to multiple alerts (via |failure_keys|). Catego rize
121 // these failures by reason (cause of failure), so that they can be grouped in the UI 125 // these failures by reason (cause of failure), so that they can be grouped in the UI
122 // (via a CTFailureGroup). Failures will be grouped in |failuresByReason|. 126 // (via a CTFailureGroup). Failures will be grouped in |failuresByReason|.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 earliestFailingBuild: failure.failing_build, 163 earliestFailingBuild: failure.failing_build,
160 masterUrl: failure.master_url, 164 masterUrl: failure.master_url,
161 failingBuildCount: failure.failing_build_count, 165 failingBuildCount: failure.failing_build_count,
162 annotation: annotations[failureKey], 166 annotation: annotations[failureKey],
163 }; 167 };
164 }.bind(this)); 168 }.bind(this));
165 169
166 if (!Object.keys(failuresByReason).length) 170 if (!Object.keys(failuresByReason).length)
167 return; 171 return;
168 172
173 // Maps a tree id to a list of CTFailures in that tree.
169 var groupedFailures = {}; 174 var groupedFailures = {};
170 Object.keys(failuresByReason, function(reasonKey, resultsByTree) { 175 Object.keys(failuresByReason, function(reasonKey, resultsByTree) {
171 var failure = JSON.parse(reasonKey); 176 var failure = JSON.parse(reasonKey);
172 Object.keys(resultsByTree, function(tree, resultsByBuilder) { 177 Object.keys(resultsByTree, function(tree, resultsByBuilder) {
173 if (!groupedFailures[tree]) 178 if (!groupedFailures[tree])
174 groupedFailures[tree] = []; 179 groupedFailures[tree] = [];
175 groupedFailures[tree].push( 180 groupedFailures[tree].push(
176 new CTFailure(failure.step, failure.reason, resultsByBuilder)); 181 new CTFailure(failure.step, failure.reason, resultsByBuilder));
177 }) 182 })
178 }); 183 });
179 184
180 Object.keys(groupedFailures, function(tree, failures) { 185 Object.keys(groupedFailures, function(tree, failures) {
181 failures.sort(this._failureComparator); 186 failures.sort(this._failureComparator);
182 187
183 if (!this.failures[tree]) 188 if (!newFailures[tree])
184 this.failures[tree] = []; 189 newFailures[tree] = [];
185 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision s); 190 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision s);
186 this.failures[tree].push(new CTFailureGroup(failures, commitList)); 191 newFailures[tree].push(new CTFailureGroup(rangeGroup.sort_key, failures, com mitList));
187 }.bind(this)); 192 }.bind(this));
188 }; 193 };
189 194
190 </script> 195 </script>
OLDNEW
« no previous file with comments | « Tools/GardeningServer/model/ct-failure-group.html ('k') | Tools/GardeningServer/model/ct-repository-commit-list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698