OLD | NEW |
| (Empty) |
1 <!-- | |
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 | |
4 found in the LICENSE file. | |
5 --> | |
6 | |
7 <link rel="import" href="../lib/log.html"> | |
8 <link rel="import" href="../lib/net.html"> | |
9 <link rel="import" href="../lib/cqstats-util.html"> | |
10 | |
11 <script> | |
12 function CQStatsRatioGraphData(columnName, project, intervalMinutes, | |
13 numeratorName, denominatorName, count) { | |
14 this.rowItemsAvailable = true; | |
15 this._numeratorName = numeratorName; | |
16 this._denominatorName = denominatorName; | |
17 this._columnName = columnName; | |
18 | |
19 this._cqStatsListPromise = cqStatsUtil.loadStats(project, intervalMinutes, | |
20 [numeratorName, denominatorName], count); | |
21 this._formattedDataPromise = this._cqStatsListPromise.then( | |
22 this._formatCQStatsList.bind(this)); | |
23 } | |
24 | |
25 CQStatsRatioGraphData.prototype._formatCQStatsList = function(cqStatsList) { | |
26 var numeratorName = this._numeratorName; | |
27 var denominatorName = this._denominatorName; | |
28 return { | |
29 cols: ['timestamp', this._columnName], | |
30 rows: cqStatsList.map(function(cqStats) { | |
31 var numeratorStat = cqStatsUtil.namedStat(numeratorName, cqStats); | |
32 var denominatorStat = cqStatsUtil.namedStat(denominatorName, cqStats); | |
33 console.assert(numeratorStat.type === 'count'); | |
34 console.assert(denominatorStat.type === 'count'); | |
35 return [ | |
36 new Date(cqStats.end * 1000), | |
37 100 * numeratorStat.count / denominatorStat.count, | |
38 ]; | |
39 }), | |
40 }; | |
41 } | |
42 | |
43 CQStatsRatioGraphData.prototype.get = function() { | |
44 return this._formattedDataPromise; | |
45 }; | |
46 | |
47 CQStatsRatioGraphData.prototype.rowItems = function(index) { | |
48 var name = this._numeratorName; | |
49 return this._cqStatsListPromise.then(function(cqStatsList) { | |
50 var cqStats = cqStatsList[index]; | |
51 return cqStatsUtil.loadStatItems(name, cqStats.key).then(function(items) { | |
52 return { | |
53 items: items, | |
54 begin: new Date(cqStats.begin * 1000), | |
55 end: new Date(cqStats.end * 1000), | |
56 }; | |
57 }); | |
58 }) | |
59 }; | |
60 </script> | |
OLD | NEW |