1 | aggregator = require('./interface')
|
2 |
|
3 | agg = aggregator.createBucketedAggregator()
|
4 |
|
5 | agg.track 'mean', aggregator: aggregator.mean.timeboxed, field: ((o) -> if o.isBot then 100 else 0)
|
6 | agg.track 'max', aggregator: aggregator.max.timeboxed, field: ((o) -> if o.isBot then 100 else 0)
|
7 | agg.track 'min', aggregator: aggregator.min.timeboxed, field: ((o) -> if o.isBot then 100 else 0)
|
8 | agg.track 'total', aggregator: aggregator.total.timeboxed, field: ((o) -> if o.isBot then 100 else 0)
|
9 | agg.track 'count', aggregator: aggregator.count.timeboxed, field: ((o) -> if o.isBot then 100 else 0)
|
10 | agg.track 'alltime mean', aggregator: aggregator.mean.alltime, field: ((o) -> if o.isBot then 100 else 0)
|
11 | agg.track 'alltime max', aggregator: aggregator.max.alltime, field: ((o) -> if o.isBot then 100 else 0)
|
12 | agg.track 'alltime min', aggregator: aggregator.min.alltime, field: ((o) -> if o.isBot then 100 else 0)
|
13 | agg.track 'alltime total', aggregator: aggregator.total.alltime, field: ((o) -> if o.isBot then 100 else 0)
|
14 | agg.track 'alltime count', aggregator: aggregator.count.alltime, field: ((o) -> if o.isBot then 100 else 0)
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | process.on 'exit', -> console.log(agg.value())
|
20 |
|
21 | jsonStream = require('./json-stream')
|
22 | jsonStream.eachRecord (record) ->
|
23 | agg.push(record.site, new Date(record.timestamp), record)
|