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

Unified Diff: masters/master.chromiumos/public_html/gantt_chart.js

Issue 2484593002: Adding gantt chart to Build Status page on Buildbot Masters (Closed)
Patch Set: rebased Created 4 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 | « masters/master.chromium/templates/build.html ('k') | masters/master.chromiumos/templates/build.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: masters/master.chromiumos/public_html/gantt_chart.js
diff --git a/masters/master.chromiumos/public_html/gantt_chart.js b/masters/master.chromiumos/public_html/gantt_chart.js
new file mode 100644
index 0000000000000000000000000000000000000000..21832cc6a38e270d932155002eeff881ff23a64f
--- /dev/null
+++ b/masters/master.chromiumos/public_html/gantt_chart.js
@@ -0,0 +1,86 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+google.charts.load('current', {'packages':['gantt']});
+
+/**
+ * reconcileSwarmingSteps reconciles a Swarming step's "trigger" step with
+ * it's subsequent "collect results" step.
+ *
+ * Swarming steps in BuildBot create two steps - one to trigger the work
+ * on swarming, and a later step to collect the results.
+ *
+ * The two steps have the same name, except the trigger step has "[trigger] "
+ * prepended to the name.
+ *
+ * This function consolidates the two steps into one by using the start
+ * time from the trigger step and the end time from the "collect results"
+ * step.
+ *
+ * This function assumes that a trigger step will be found before the
+ * corresponding "collect results" step in the list of steps.
+ * @param {Array<Object>} steps List of step objects. Each step object
+ * has the following properties: name {string}, start {Date}, end {Date}
+ */
+function reconcileSwarmingSteps(steps) {
+ let reconciledSteps = [];
+ let triggerSteps = {};
+
+ for (let s of steps) {
+ // trigger steps have names like "[trigger] TheRestOfTheNameGoesHere..."
+ let isTriggerStep = /\[trigger\] (.*)/.exec(s.name);
+ if (isTriggerStep) {
+ triggerSteps[isTriggerStep[1]] = s;
+ } else {
+ if (triggerSteps[s.name]) {
+ s.start = triggerSteps[s.name].start;
+ }
+ reconciledSteps.push(s);
+ }
+ }
+
+ return reconciledSteps;
+};
+
+function drawChart(steps) {
+ let data = new google.visualization.DataTable();
+ data.addColumn('string', 'Task ID');
+ data.addColumn('string', 'Task Name');
+ data.addColumn('string', 'Resource');
+ data.addColumn('date', 'Start Date');
+ data.addColumn('date', 'End Date');
+ data.addColumn('number', 'Duration');
+ data.addColumn('number', 'Percent Complete');
+ data.addColumn('string', 'Dependencies');
+
+ for (s of steps) {
+ data.addRow([s.name, s.name, null, s.start, s.end, null, 100, null]);
+ }
+
+ let trackHeight = 25;
+ let options = {
+ height: data.getNumberOfRows() * trackHeight,
+ gantt: {
+ trackHeight: trackHeight,
+ barHeight: trackHeight * 0.8,
+ labelMaxWidth: 500,
+ }
+ };
+
+ let chart = new google.visualization.Gantt(
+ document.getElementById('chart_div'));
+ chart.draw(data, options);
+}
+
+let chartVisible = false;
+function toggleChart(rawSteps) {
+ if (chartVisible) {
+ document.getElementById('chart_div').style.display = 'none';
+ chartVisible = false;
+ } else {
+ document.getElementById('chart_div').style.display = 'block';
+ let steps = reconcileSwarmingSteps(rawSteps);
+ drawChart(steps);
+ chartVisible = true;
+ }
+}
« no previous file with comments | « masters/master.chromium/templates/build.html ('k') | masters/master.chromiumos/templates/build.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698