-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreports.js
More file actions
41 lines (29 loc) · 817 Bytes
/
reports.js
File metadata and controls
41 lines (29 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var _ = require('lodash');
var reports = {
measurements: {
// A key to identify a report instance
computeKey: function (field, level, reportName, key) {
var kp = [field, level, reportName];
if (_.isArray(key))
kp.push(...key);
else
kp.push(key);
return kp.join('/');
},
// Functions to consolidate data points (aggregate at next level).
consolidateFuncs: {
'AVERAGE': (a) => (
a.length? ((a.length > 1)? (_.sum(a)/a.length) : (a[0])) : null
),
'MIN': (a) => (_.min(a)),
'MAX': (a) => (_.max(a)),
},
},
system: {
// A key to identify a report instance
computeKey: function (level, reportName) {
return [level, reportName].join('/');
},
},
};
module.exports = reports;