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

Side by Side Diff: appengine_apps/trooper_o_matic/model/cqstats-graph-data.html

Issue 774323002: Moved trooper_o_matic to appengine/ (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 6 years 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
(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 CQStatsGraphData(name, cqStatsListPromise) {
13 this.rowItemsAvailable = true;
14 this._name = name;
15 this._cqStatsListPromise = cqStatsListPromise;
16 this._formattedDataPromise = cqStatsListPromise.then(
17 this._formatCQStatsList.bind(this));
18 }
19
20 CQStatsGraphData.createBatch = function(
21 project, intervalMinutes, names, count) {
22 var cqStatsListPromise = cqStatsUtil.loadStats(
23 project, intervalMinutes, names, count).catch(log);
24 return names.map(function(name) {
25 return new CQStatsGraphData(name, cqStatsListPromise);
26 });
27 };
28
29 CQStatsGraphData.prototype._formatCQStatsList = function(cqStatsList) {
30 var name = this._name;
31 return {
32 cols: ['timestamp', 'max', 'p90', 'p50', 'min', 'mean'],
33 rows: cqStatsList.map(function(cqStats) {
34 var stat = null;
35 cqStats.stats.forEach(function(testStat) {
36 if (testStat.name === name) {
37 stat = testStat;
38 }
39 });
40 // Convert timestamps to Date objects and seconds to minutes.
41 return [
42 new Date(cqStats.end * 1000),
43 stat.max / 60,
44 stat.percentile_90 / 60,
45 stat.percentile_50 / 60,
46 stat.min / 60,
47 stat.mean / 60,
48 ];
49 }),
50 };
51 }
52
53 CQStatsGraphData.prototype.get = function() {
54 return this._formattedDataPromise;
55 };
56
57 CQStatsGraphData.prototype.rowItems = function(index) {
58 var name = this._name;
59 return this._cqStatsListPromise.then(function(cqStatsList) {
60 var cqStats = cqStatsList[index];
61 return cqStatsUtil.loadStatItems(name, cqStats.key).then(function(items) {
62 // Convert seconds to minutes.
63 items.forEach(function(item) { item[0] /= 60; });
64 return {
65 items: items,
66 begin: new Date(cqStats.begin * 1000),
67 end: new Date(cqStats.end * 1000),
68 };
69 });
70 })
71 };
72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698