1 window.App = Ember.Application.create();
3 App.Router.map(function () {
4 this.resource('charts', {path: 'charts'});
5 this.resource('analysis', {path: 'analysis'});
6 this.resource('analysisTask', {path: 'analysis/task/:taskId'});
9 App.DashboardRow = Ember.Object.extend({
17 var cellsInfo = this.get('cellsInfo') || [];
18 var columnCount = this.get('columnCount');
19 while (cellsInfo.length < columnCount)
22 this.set('cells', cellsInfo.map(this._createPane.bind(this)));
24 addPane: function (paneInfo)
26 var pane = this._createPane(paneInfo);
27 this.get('cells').pushObject(pane);
28 this.set('columnCount', this.get('columnCount') + 1);
30 _createPane: function (paneInfo)
32 if (!paneInfo || !paneInfo.length || (!paneInfo[0] && !paneInfo[1]))
35 var pane = App.Pane.create({
36 store: this.get('store'),
37 platformId: paneInfo ? paneInfo[0] : null,
38 metricId: paneInfo ? paneInfo[1] : null,
41 return App.DashboardPaneProxyForPicker.create({content: pane});
45 App.DashboardPaneProxyForPicker = Ember.ObjectProxy.extend({
46 _platformOrMetricIdChanged: function ()
49 App.buildPopup(this.get('store'), 'choosePane', this)
50 .then(function (platforms) { self.set('pickerData', platforms); });
51 }.observes('platformId', 'metricId').on('init'),
52 paneList: function () {
53 return App.encodePrettifiedJSON([[this.get('platformId'), this.get('metricId'), null, null, false]]);
54 }.property('platformId', 'metricId'),
57 App.IndexController = Ember.Controller.extend({
58 queryParams: ['grid', 'numberOfDays'],
65 gridChanged: function ()
67 var grid = this.get('grid');
68 if (grid === this._previousGrid)
73 dashboard = App.Dashboard.create({serialized: grid});
74 if (!dashboard.get('headerColumns').length)
78 dashboard = App.Manifest.get('defaultDashboard');
82 var headerColumns = dashboard.get('headerColumns');
83 this.set('headerColumns', headerColumns);
84 var columnCount = headerColumns.length;
85 this.set('columnCount', columnCount);
87 var store = this.store;
88 this.set('rows', dashboard.get('rows').map(function (rowParam) {
89 return App.DashboardRow.create({
92 cellsInfo: rowParam.slice(1),
93 columnCount: columnCount,
97 this.set('emptyRow', new Array(columnCount));
98 }.observes('grid', 'App.Manifest.defaultDashboard').on('init'),
100 updateGrid: function()
102 var headers = this.get('headerColumns').map(function (header) { return header.label; });
103 var table = [headers].concat(this.get('rows').map(function (row) {
104 return [row.get('header')].concat(row.get('cells').map(function (pane) {
105 var platformAndMetric = [pane.get('platformId'), pane.get('metricId')];
106 return platformAndMetric[0] || platformAndMetric[1] ? platformAndMetric : [];
109 this._previousGrid = JSON.stringify(table);
110 this.set('grid', this._previousGrid);
113 _sharedDomainChanged: function ()
115 var numberOfDays = this.get('numberOfDays');
119 numberOfDays = parseInt(numberOfDays);
120 var present = Date.now();
121 var past = present - numberOfDays * 24 * 3600 * 1000;
122 this.set('since', past);
123 this.set('sharedDomain', [past, present]);
124 }.observes('numberOfDays').on('init'),
127 setNumberOfDays: function (numberOfDays)
129 this.set('numberOfDays', numberOfDays);
131 choosePane: function (param)
133 var pane = param.position;
134 pane.set('platformId', param.platform.get('id'));
135 pane.set('metricId', param.metric.get('id'));
137 addColumn: function ()
139 this.get('headerColumns').pushObject({
140 label: this.get('newColumnHeader'),
141 index: this.get('headerColumns').length,
143 this.get('rows').forEach(function (row) {
146 this.set('newColumnHeader', null);
148 removeColumn: function (index)
150 this.get('headerColumns').removeAt(index);
151 this.get('rows').forEach(function (row) {
152 row.get('cells').removeAt(index);
157 this.get('rows').pushObject(App.DashboardRow.create({
159 header: this.get('newRowHeader'),
160 columnCount: this.get('columnCount'),
162 this.set('newRowHeader', null);
164 removeRow: function (row)
166 this.get('rows').removeObject(row);
168 resetPane: function (pane)
170 pane.set('platformId', null);
171 pane.set('metricId', null);
173 toggleEditMode: function ()
175 this.toggleProperty('editMode');
176 if (!this.get('editMode'))
184 App.Manifest.fetch(this.get('store'));
188 App.NumberOfDaysControlView = Ember.View.extend({
189 classNames: ['controls'],
190 templateName: 'number-of-days-controls',
191 didInsertElement: function ()
193 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
195 _numberOfDaysChanged: function ()
197 this._matchingElements(this._previousNumberOfDaysClass).removeClass('active');
199 var newNumberOfDaysClass = 'numberOfDaysIs' + this.get('numberOfDays');
200 this._matchingElements(this._previousNumberOfDaysClass).addClass('active');
201 this._previousNumberOfDaysClass = newNumberOfDaysClass;
202 }.observes('numberOfDays').on('init'),
203 _matchingElements: function (className)
205 var element = this.get('element');
208 return $(element.getElementsByClassName(className));
212 App.StartTimeSliderView = Ember.View.extend({
213 templateName: 'start-time-slider',
214 classNames: ['start-time-slider'],
215 startTime: Date.now() - 7 * 24 * 3600 * 1000,
216 oldestStartTime: null,
217 _numberOfDaysView: null,
219 _startTimeInSlider: null,
220 _currentNumberOfDays: null,
221 _MILLISECONDS_PER_DAY: 24 * 3600 * 1000,
223 didInsertElement: function ()
225 this.oldestStartTime = Date.now() - 365 * 24 * 3600 * 1000;
226 this._slider = $(this.get('element')).find('input');
227 this._numberOfDaysView = $(this.get('element')).find('.numberOfDays');
228 this._sliderRangeChanged();
229 this._slider.change(this._sliderMoved.bind(this));
231 _sliderRangeChanged: function ()
233 var minimumNumberOfDays = 1;
234 var maximumNumberOfDays = this._timeInPastToNumberOfDays(this.get('oldestStartTime'));
235 var precision = 1000; // FIXME: Compute this from maximumNumberOfDays.
236 var slider = this._slider;
237 slider.attr('min', Math.floor(Math.log(Math.max(1, minimumNumberOfDays)) * precision) / precision);
238 slider.attr('max', Math.ceil(Math.log(maximumNumberOfDays) * precision) / precision);
239 slider.attr('step', 1 / precision);
240 this._startTimeChanged();
241 }.observes('oldestStartTime'),
242 _sliderMoved: function ()
244 this._currentNumberOfDays = Math.round(Math.exp(this._slider.val()));
245 this._numberOfDaysView.text(this._currentNumberOfDays);
246 this._startTimeInSlider = this._numberOfDaysToTimeInPast(this._currentNumberOfDays);
247 this.set('startTime', this._startTimeInSlider);
249 _startTimeChanged: function ()
251 var startTime = this.get('startTime');
252 if (startTime == this._startTimeSetBySlider)
254 this._currentNumberOfDays = this._timeInPastToNumberOfDays(startTime);
257 this._numberOfDaysView.text(this._currentNumberOfDays);
258 this._slider.val(Math.log(this._currentNumberOfDays));
259 this._startTimeInSlider = startTime;
261 }.observes('startTime').on('init'),
262 _timeInPastToNumberOfDays: function (timeInPast)
264 return Math.max(1, Math.round((Date.now() - timeInPast) / this._MILLISECONDS_PER_DAY));
266 _numberOfDaysToTimeInPast: function (numberOfDays)
268 return Date.now() - numberOfDays * this._MILLISECONDS_PER_DAY;
272 App.Pane = Ember.Object.extend({
278 searchCommit: function (repository, keyword) {
280 var repositoryId = repository.get('id');
281 CommitLogs.fetchForTimeRange(repositoryId, null, null, keyword).then(function (commits) {
282 if (self.isDestroyed || !self.get('chartData') || !commits.length)
284 var currentRuns = self.get('chartData').current.timeSeriesByCommitTime().series();
285 if (!currentRuns.length)
288 var highlightedItems = {};
290 for (var runIndex = 0; runIndex < currentRuns.length && commitIndex < commits.length; runIndex++) {
291 var measurement = currentRuns[runIndex].measurement;
292 var commitTime = measurement.commitTimeForRepository(repositoryId);
295 if (commits[commitIndex].time <= commitTime) {
296 highlightedItems[measurement.id()] = true;
299 } while (commitIndex < commits.length && commits[commitIndex].time <= commitTime);
303 self.set('highlightedItems', highlightedItems);
305 // FIXME: Report errors
306 this.set('highlightedItems', {});
309 _fetch: function () {
310 var platformId = this.get('platformId');
311 var metricId = this.get('metricId');
312 if (!platformId && !metricId) {
313 this.set('empty', true);
316 this.set('empty', false);
317 this.set('platform', null);
318 this.set('chartData', null);
319 this.set('metric', null);
320 this.set('failure', null);
322 if (!this._isValidId(platformId))
323 this.set('failure', platformId ? 'Invalid platform id:' + platformId : 'Platform id was not specified');
324 else if (!this._isValidId(metricId))
325 this.set('failure', metricId ? 'Invalid metric id:' + metricId : 'Metric id was not specified');
329 App.Manifest.fetchRunsWithPlatformAndMetric(this.get('store'), platformId, metricId).then(function (result) {
330 self.set('platform', result.platform);
331 self.set('metric', result.metric);
332 self.set('chartData', result.runs);
333 }, function (result) {
334 if (!result || typeof(result) === "string")
335 self.set('failure', 'Failed to fetch the JSON with an error: ' + result);
336 else if (!result.platform)
337 self.set('failure', 'Could not find the platform "' + platformId + '"');
338 else if (!result.metric)
339 self.set('failure', 'Could not find the metric "' + metricId + '"');
341 self.set('failure', 'An internal error');
344 this.fetchAnalyticRanges();
346 }.observes('platformId', 'metricId').on('init'),
347 fetchAnalyticRanges: function ()
349 var platformId = this.get('platformId');
350 var metricId = this.get('metricId');
353 .find('analysisTask', {platform: platformId, metric: metricId})
354 .then(function (tasks) {
355 self.set('analyticRanges', tasks.filter(function (task) { return task.get('startRun') && task.get('endRun'); }));
358 _isValidId: function (id)
360 if (typeof(id) == "number")
362 if (typeof(id) == "string")
363 return !!id.match(/^[A-Za-z0-9_]+$/);
368 App.encodePrettifiedJSON = function (plain)
370 function numberIfPossible(string) {
371 return string == parseInt(string) ? parseInt(string) : string;
374 function recursivelyConvertNumberIfPossible(input) {
375 if (input instanceof Array) {
376 return input.map(recursivelyConvertNumberIfPossible);
378 return numberIfPossible(input);
381 return JSON.stringify(recursivelyConvertNumberIfPossible(plain))
382 .replace(/\[/g, '(').replace(/\]/g, ')').replace(/\,/g, '-');
385 App.decodePrettifiedJSON = function (encoded)
387 var parsed = encoded.replace(/\(/g, '[').replace(/\)/g, ']').replace(/\-/g, ',');
389 return JSON.parse(parsed);
390 } catch (exception) {
395 App.ChartsController = Ember.Controller.extend({
396 queryParams: ['paneList', 'zoom', 'since'],
398 _currentEncodedPaneList: null,
404 defaultSince: Date.now() - 7 * 24 * 3600 * 1000,
406 addPane: function (pane)
408 this.panes.unshiftObject(pane);
411 removePane: function (pane)
413 this.panes.removeObject(pane);
416 refreshPanes: function()
418 var paneList = this.get('paneList');
419 if (paneList === this._currentEncodedPaneList)
422 var panes = this._parsePaneList(paneList || '[]');
424 console.log('Failed to parse', jsonPaneList, exception);
427 this.set('panes', panes);
428 this._currentEncodedPaneList = paneList;
429 }.observes('paneList').on('init'),
431 refreshZoom: function()
433 var zoom = this.get('zoom');
435 this.set('sharedZoom', null);
439 zoom = zoom.split('-');
440 var selection = new Array(2);
442 selection[0] = new Date(parseFloat(zoom[0]));
443 selection[1] = new Date(parseFloat(zoom[1]));
445 console.log('Failed to parse the zoom', zoom);
447 this.set('sharedZoom', selection);
449 var startTime = this.get('startTime');
450 if (startTime && startTime > selection[0])
451 this.set('startTime', selection[0]);
453 }.observes('zoom').on('init'),
455 _startTimeChanged: function () {
456 this.set('sharedDomain', [this.get('startTime'), this.get('present')]);
457 this._scheduleQueryStringUpdate();
458 }.observes('startTime'),
460 _sinceChanged: function () {
461 var since = parseInt(this.get('since'));
463 since = this.defaultSince;
464 this.set('startTime', new Date(since));
465 }.observes('since').on('init'),
467 _parsePaneList: function (encodedPaneList)
469 var parsedPaneList = App.decodePrettifiedJSON(encodedPaneList);
473 // Don't re-create all panes.
475 return parsedPaneList.map(function (paneInfo) {
476 var timeRange = null;
477 if (paneInfo[3] && paneInfo[3] instanceof Array) {
478 var timeRange = paneInfo[3];
480 timeRange = [new Date(timeRange[0]), new Date(timeRange[1])];
482 console.log("Failed to parse the time range:", timeRange, error);
485 return App.Pane.create({
488 platformId: paneInfo[0],
489 metricId: paneInfo[1],
490 selectedItem: paneInfo[2],
491 timeRange: timeRange,
492 timeRangeIsLocked: !!paneInfo[4],
497 _serializePaneList: function (panes)
501 return App.encodePrettifiedJSON(panes.map(function (pane) {
503 pane.get('platformId'),
504 pane.get('metricId'),
505 pane.get('selectedItem'),
506 pane.get('timeRange') ? pane.get('timeRange').map(function (date) { return date.getTime() }) : null,
507 !!pane.get('timeRangeIsLocked'),
512 _scheduleQueryStringUpdate: function ()
514 Ember.run.debounce(this, '_updateQueryString', 1000);
515 }.observes('sharedZoom', 'panes.@each.platform', 'panes.@each.metric', 'panes.@each.selectedItem',
516 'panes.@each.timeRange', 'panes.@each.timeRangeIsLocked'),
518 _updateQueryString: function ()
520 this._currentEncodedPaneList = this._serializePaneList(this.get('panes'));
521 this.set('paneList', this._currentEncodedPaneList);
523 var zoom = undefined;
524 var sharedZoom = this.get('sharedZoom');
525 if (sharedZoom && !App.domainsAreEqual(sharedZoom, this.get('sharedDomain')))
526 zoom = +sharedZoom[0] + '-' + +sharedZoom[1];
527 this.set('zoom', zoom);
529 if (this.get('startTime') - this.defaultSince)
530 this.set('since', this.get('startTime') - 0);
534 addPaneByMetricAndPlatform: function (param)
536 this.addPane(App.Pane.create({
538 platformId: param.platform.get('id'),
539 metricId: param.metric.get('id'),
540 showingDetails: false
549 App.buildPopup(this.store, 'addPaneByMetricAndPlatform').then(function (platforms) {
550 self.set('platforms', platforms);
555 App.buildPopup = function(store, action, position)
557 return App.Manifest.fetch(store).then(function () {
558 return App.Manifest.get('platforms').map(function (platform) {
559 return App.PlatformProxyForPopup.create({content: platform,
560 action: action, position: position});
565 App.PlatformProxyForPopup = Ember.ObjectProxy.extend({
566 children: function ()
568 var platform = this.content;
569 var containsTest = this.content.containsTest.bind(this.content);
570 var action = this.get('action');
571 var position = this.get('position');
572 return App.Manifest.get('topLevelTests')
573 .filter(containsTest)
574 .map(function (test) {
575 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
577 }.property('App.Manifest.topLevelTests'),
580 App.TestProxyForPopup = Ember.ObjectProxy.extend({
582 children: function ()
584 var platform = this.get('platform');
585 var action = this.get('action');
586 var position = this.get('position');
588 var childTests = this.get('childTests')
589 .filter(function (test) { return platform.containsTest(test); })
590 .map(function (test) {
591 return App.TestProxyForPopup.create({content: test, platform: platform, action: action, position: position});
594 var metrics = this.get('metrics')
595 .filter(function (metric) { return platform.containsMetric(metric); })
596 .map(function (metric) {
597 var aggregator = metric.get('aggregator');
600 actionArgument: {platform: platform, metric: metric, position:position},
601 label: metric.get('label')
605 if (childTests.length && metrics.length)
606 metrics.push({isSeparator: true});
608 return metrics.concat(childTests);
609 }.property('childTests', 'metrics'),
612 App.domainsAreEqual = function (domain1, domain2) {
613 return (!domain1 && !domain2) || (domain1 && domain2 && !(domain1[0] - domain2[0]) && !(domain1[1] - domain2[1]));
616 App.PaneController = Ember.ObjectController.extend({
618 sharedTime: Ember.computed.alias('parentController.sharedTime'),
619 sharedSelection: Ember.computed.alias('parentController.sharedSelection'),
622 toggleDetails: function()
624 this.toggleProperty('showingDetails');
628 this.parentController.removePane(this.get('model'));
630 toggleBugsPane: function ()
632 if (this.toggleProperty('showingAnalysisPane'))
633 this.set('showingSearchPane', false);
635 createAnalysisTask: function ()
637 var name = this.get('newAnalysisTaskName');
638 var points = this.get('selectedPoints');
639 Ember.assert('The analysis name should not be empty', name);
640 Ember.assert('There should be at least two points in the range', points && points.length >= 2);
642 var newWindow = window.open();
644 App.AnalysisTask.create(name, points[0].measurement, points[points.length - 1].measurement).then(function (data) {
645 // FIXME: Update the UI to show the new analysis task.
646 var url = App.Router.router.generate('analysisTask', data['taskId']);
647 newWindow.location.href = '#' + url;
648 self.get('model').fetchAnalyticRanges();
649 }, function (error) {
651 if (error === 'DuplicateAnalysisTask') {
652 // FIXME: Duplicate this error more gracefully.
657 toggleSearchPane: function ()
659 if (!App.Manifest.repositoriesWithReportedCommits)
661 var model = this.get('model');
662 if (!model.get('commitSearchRepository'))
663 model.set('commitSearchRepository', App.Manifest.repositoriesWithReportedCommits[0]);
664 if (this.toggleProperty('showingSearchPane'))
665 this.set('showingAnalysisPane', false);
667 searchCommit: function () {
668 var model = this.get('model');
669 model.searchCommit(model.get('commitSearchRepository'), model.get('commitSearchKeyword'));
671 zoomed: function (selection)
673 this.set('mainPlotDomain', selection ? selection : this.get('overviewDomain'));
674 Ember.run.debounce(this, 'propagateZoom', 100);
677 _detailsChanged: function ()
679 this.set('showingAnalysisPane', false);
680 }.observes('details'),
681 _overviewSelectionChanged: function ()
683 var overviewSelection = this.get('overviewSelection');
684 if (App.domainsAreEqual(overviewSelection, this.get('mainPlotDomain')))
686 this.set('mainPlotDomain', overviewSelection || this.get('overviewDomain'));
687 Ember.run.debounce(this, 'propagateZoom', 100);
688 }.observes('overviewSelection'),
689 _sharedDomainChanged: function ()
691 var newDomain = this.get('parentController').get('sharedDomain');
692 if (App.domainsAreEqual(newDomain, this.get('overviewDomain')))
694 this.set('overviewDomain', newDomain);
695 if (!this.get('overviewSelection'))
696 this.set('mainPlotDomain', newDomain);
697 }.observes('parentController.sharedDomain').on('init'),
698 propagateZoom: function ()
700 this.get('parentController').set('sharedZoom', this.get('mainPlotDomain'));
702 _sharedZoomChanged: function ()
704 var newSelection = this.get('parentController').get('sharedZoom');
705 if (App.domainsAreEqual(newSelection, this.get('mainPlotDomain')))
707 this.set('mainPlotDomain', newSelection);
708 this.set('overviewSelection', newSelection);
709 }.observes('parentController.sharedZoom').on('init'),
710 _updateDetails: function ()
712 var selectedPoints = this.get('selectedPoints');
713 var currentPoint = this.get('currentItem');
714 if (!selectedPoints && !currentPoint) {
715 this.set('details', null);
719 var currentMeasurement;
722 currentMeasurement = currentPoint.measurement;
723 var previousPoint = currentPoint.series.previousPoint(currentPoint);
724 oldMeasurement = previousPoint ? previousPoint.measurement : null;
726 currentMeasurement = selectedPoints[selectedPoints.length - 1].measurement;
727 oldMeasurement = selectedPoints[0].measurement;
730 var formattedRevisions = currentMeasurement.formattedRevisions(oldMeasurement);
731 var revisions = App.Manifest.get('repositories')
732 .filter(function (repository) { return formattedRevisions[repository.get('id')]; })
733 .map(function (repository) {
734 var revision = Ember.Object.create(formattedRevisions[repository.get('id')]);
735 revision['url'] = revision.previousRevision
736 ? repository.urlForRevisionRange(revision.previousRevision, revision.currentRevision)
737 : repository.urlForRevision(revision.currentRevision);
738 revision['name'] = repository.get('name');
739 revision['repository'] = repository;
743 var buildNumber = null;
746 buildNumber = currentMeasurement.buildNumber();
747 var builder = App.Manifest.builder(currentMeasurement.builderId());
749 buildURL = builder.urlFromBuildNumber(buildNumber);
752 this.set('details', Ember.Object.create({
753 currentValue: currentMeasurement.mean().toFixed(2),
754 oldValue: oldMeasurement && selectedPoints ? oldMeasurement.mean().toFixed(2) : null,
755 buildNumber: buildNumber,
757 buildTime: currentMeasurement.formattedBuildTime(),
758 revisions: revisions,
760 this._updateCanAnalyze();
761 }.observes('currentItem', 'selectedPoints'),
762 _updateCanAnalyze: function ()
764 var points = this.get('selectedPoints');
765 this.set('cannotAnalyze', !this.get('newAnalysisTaskName') || !points || points.length < 2);
766 }.observes('newAnalysisTaskName'),
770 App.AnalysisRoute = Ember.Route.extend({
772 return this.store.findAll('analysisTask').then(function (tasks) {
773 return Ember.Object.create({'tasks': tasks});
778 App.AnalysisTaskRoute = Ember.Route.extend({
779 model: function (param)
781 return this.store.find('analysisTask', param.taskId);
785 App.AnalysisTaskController = Ember.Controller.extend({
786 label: Ember.computed.alias('model.name'),
787 platform: Ember.computed.alias('model.platform'),
788 metric: Ember.computed.alias('model.metric'),
789 testGroups: Ember.computed.alias('model.testGroups'),
793 possibleRepetitionCounts: [1, 2, 3, 4, 5, 6],
794 _taskUpdated: function ()
796 var model = this.get('model');
800 var platformId = model.get('platform').get('id');
801 var metricId = model.get('metric').get('id');
802 App.Manifest.fetch(this.store).then(this._fetchedManifest.bind(this));
803 App.Manifest.fetchRunsWithPlatformAndMetric(this.store, platformId, metricId).then(this._fetchedRuns.bind(this));
804 }.observes('model').on('init'),
805 _fetchedManifest: function ()
807 var trackerIdToBugNumber = {};
808 this.get('model').get('bugs').forEach(function (bug) {
809 trackerIdToBugNumber[bug.get('bugTracker').get('id')] = bug.get('number');
812 this.set('bugTrackers', App.Manifest.get('bugTrackers').map(function (bugTracker) {
813 var bugNumber = trackerIdToBugNumber[bugTracker.get('id')];
814 return Ember.ObjectProxy.create({
816 bugNumber: bugNumber,
817 editedBugNumber: bugNumber,
821 _fetchedRuns: function (data)
823 var runs = data.runs;
825 var currentTimeSeries = runs.current.timeSeriesByCommitTime();
826 if (!currentTimeSeries)
827 return; // FIXME: Report an error.
829 var start = currentTimeSeries.findPointByMeasurementId(this.get('model').get('startRun'));
830 var end = currentTimeSeries.findPointByMeasurementId(this.get('model').get('endRun'));
832 return; // FIXME: Report an error.
834 var highlightedItems = {};
835 highlightedItems[start.measurement.id()] = true;
836 highlightedItems[end.measurement.id()] = true;
838 var formatedPoints = currentTimeSeries.seriesBetweenPoints(start, end).map(function (point, index) {
840 id: point.measurement.id(),
841 measurement: point.measurement,
842 label: 'Point ' + (index + 1),
843 value: point.value + (runs.unit ? ' ' + runs.unit : ''),
847 var margin = (end.time - start.time) * 0.1;
848 this.set('chartData', runs);
849 this.set('chartDomain', [start.time - margin, +end.time + margin]);
850 this.set('highlightedItems', highlightedItems);
851 this.set('analysisPoints', formatedPoints);
853 testSets: function ()
855 var analysisPoints = this.get('analysisPoints');
858 var pointOptions = [{value: ' ', label: 'None'}]
859 .concat(analysisPoints.map(function (point) { return {value: point.id, label: point.label}; }));
861 Ember.Object.create({name: "A", options: pointOptions, selection: pointOptions[1]}),
862 Ember.Object.create({name: "B", options: pointOptions, selection: pointOptions[pointOptions.length - 1]}),
864 }.property('analysisPoints'),
865 _rootChangedForTestSet: function ()
867 var sets = this.get('testSets');
868 var roots = this.get('roots');
872 sets.forEach(function (testSet, setIndex) {
873 var currentSelection = testSet.get('selection');
874 if (currentSelection == testSet.get('previousSelection'))
876 testSet.set('previousSelection', currentSelection);
877 var pointIndex = testSet.get('options').indexOf(currentSelection);
879 roots.forEach(function (root) {
880 var set = root.sets[setIndex];
881 set.set('selection', set.revisions[pointIndex]);
885 }.observes('testSets.@each.selection'),
886 updateRoots: function ()
888 var analysisPoints = this.get('analysisPoints');
891 var repositoryToRevisions = {};
892 analysisPoints.forEach(function (point, pointIndex) {
893 var revisions = point.measurement.formattedRevisions();
894 for (var repositoryId in revisions) {
895 if (!repositoryToRevisions[repositoryId])
896 repositoryToRevisions[repositoryId] = new Array(analysisPoints.length);
897 var revision = revisions[repositoryId];
898 repositoryToRevisions[repositoryId][pointIndex] = {
899 label: point.label + ': ' + revision.label,
900 value: revision.currentRevision,
906 this.get('model').get('triggerable').then(function (triggerable) {
910 self.set('roots', triggerable.get('acceptedRepositories').map(function (repository) {
911 var repositoryId = repository.get('id');
912 var revisions = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryId]);
913 return Ember.Object.create({
914 name: repository.get('name'),
916 Ember.Object.create({name: 'A[' + repositoryId + ']',
917 revisions: revisions,
918 selection: revisions[1]}),
919 Ember.Object.create({name: 'B[' + repositoryId + ']',
920 revisions: revisions,
921 selection: revisions[revisions.length - 1]}),
926 }.observes('analysisPoints'),
928 associateBug: function (bugTracker, bugNumber)
930 var model = this.get('model');
931 this.store.createRecord('bug',
932 {task: this.get('model'), bugTracker: bugTracker.get('content'), number: bugNumber}).save().then(function () {
933 // FIXME: Should we notify the user?
934 }, function (error) {
935 alert('Failed to associate the bug: ' + error);
938 createTestGroup: function (name, repetitionCount)
941 this.get('roots').map(function (root) {
942 roots[root.get('name')] = root.get('sets').map(function (item) { return item.get('selection').value; });
944 App.TestGroup.create(this.get('model'), name, roots, repetitionCount).then(function () {