forked from lukasmartinelli/osm-activity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.js
More file actions
47 lines (41 loc) · 1.16 KB
/
Copy pathstats.js
File metadata and controls
47 lines (41 loc) · 1.16 KB
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
42
43
44
45
46
47
'use strict';
const _ = require('lodash');
const Stats = require('fast-stats').Stats;
function statisticsReport(stats) {
return {
mean: stats.amean(),
percentile: {
"10": stats.percentile(10),
"20": stats.percentile(20),
"30": stats.percentile(30),
"40": stats.percentile(40),
"50": stats.percentile(50),
"60": stats.percentile(60),
"70": stats.percentile(70),
"80": stats.percentile(80),
"90": stats.percentile(90),
"95": stats.percentile(95),
"99": stats.percentile(99),
}
};
}
class ChangelogStats {
constructor() {
//All values lower than lowThreshold are discarded
//like a bandpass filter
this.lowThreshold = 5;
this.globalStats = new Stats();
}
trackTile(changelog) {
const props = changelog.properties;
if (props.total > this.lowThreshold) {
this.globalStats.push(props.total);
}
}
report() {
return {
global: statisticsReport(this.globalStats),
};
}
}
module.exports = ChangelogStats;