Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 45c9fe1

Browse files
committed
Now supports reductio.valueList and reductio.dataList
1 parent a569c43 commit 45c9fe1

File tree

5 files changed

+90
-5
lines changed

5 files changed

+90
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "universe",
3-
"version": "0.4.2",
3+
"version": "0.5.0",
44
"description": "The fastest way to query and explore multivariate datasets",
55
"main": "src/universe.js",
66
"directories": {

src/reductioAggregators.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ module.exports = {
2222
$med: $med,
2323
$sumSq: $sumSq,
2424
$std: $std,
25+
$valueList: $valueList,
26+
$dataList: $dataList,
2527
}
2628
}
2729

@@ -59,5 +61,13 @@ function $std(reducer, value) {
5961
return reducer.std(value)
6062
}
6163

64+
function $valueList(reducer, value) {
65+
return reducer.valueList(value)
66+
}
67+
68+
function $dataList(reducer, value) {
69+
return reducer.dataList(value)
70+
}
71+
6272
// TODO histograms
6373
// TODO exceptions

test/query.spec.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,71 @@ describe('universe query', function() {
321321
})
322322
})
323323

324+
it('can query using the valueList aggregation', function() {
325+
var res
326+
return u.then(function(u){
327+
return u.query({
328+
groupBy: 'type',
329+
select: {
330+
$valueList: 'total',
331+
}
332+
})
333+
})
334+
.then(function(r){
335+
res = r
336+
expect(res.data).to.deep.equal([
337+
{ key: 'cash', value: { valueList: [100, 200] } },
338+
{ key: 'tab', value: { valueList: [90, 90, 90, 90, 90, 90, 190, 190] } },
339+
{ key: 'visa', value: { valueList: [200, 300, 50000] } } ])
340+
})
341+
})
342+
343+
it('can query using the dataList aggregation', function() {
344+
var res
345+
return u.then(function(u){
346+
return u.query({
347+
groupBy: 'type',
348+
select: {
349+
$dataList: 'total',
350+
}
351+
})
352+
})
353+
.then(function(r){
354+
res = r
355+
expect(res.data).to.deep.equal([{
356+
"key": "cash",
357+
"value": {
358+
"dataList": [
359+
{"date": "2011-11-14T16:54:06Z","quantity": 1,"total": 100, "tip": 0,"type": "cash","productIDs": ["001", "002", "003", "004", "005"]},
360+
{"date": "2011-11-14T17:25:45Z","quantity": 2,"total": 200, "tip": 0,"type": "cash","productIDs": ["002"]}
361+
]
362+
}
363+
}, {
364+
"key": "tab",
365+
"value": {
366+
"dataList": [
367+
{"date": "2011-11-14T16:17:54Z","quantity": 2,"total": 190, "tip": 100,"type": "tab","productIDs": ["001"]},
368+
{"date": "2011-11-14T16:20:19Z","quantity": 2,"total": 190, "tip": 100,"type": "tab","productIDs": ["001", "005"]},
369+
{"date": "2011-11-14T16:30:43Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["001", "002"]},
370+
{"date": "2011-11-14T16:48:46Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["005"]},
371+
{"date": "2011-11-14T16:53:41Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["001", "004", "005"]},
372+
{"date": "2011-11-14T16:58:03Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["001"]},
373+
{"date": "2011-11-14T17:07:21Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["004", "005"]},
374+
{"date": "2011-11-14T17:22:59Z","quantity": 2,"total": 90, "tip": 0,"type": "tab","productIDs": ["001", "002", "004", "005"]}
375+
]
376+
}
377+
}, {
378+
"key": "visa",
379+
"value": {
380+
"dataList": [
381+
{"date": "2011-11-14T16:28:54Z","quantity": 1,"total": 300, "tip": 200,"type": "visa","productIDs": ["004", "005"]},
382+
{"date": "2011-11-14T17:29:52Z","quantity": 1,"total": 200, "tip": 100,"type": "visa","productIDs": ["004"]},
383+
{"date": "2012-11-14T17:29:52Z","quantity": 100,"total": 50000, "tip": 999,"type": "visa","productIDs": ["004"]}
384+
]}
385+
}])
386+
})
387+
})
388+
324389
// TODO: This isn't completely possible yet, reductio will need to support aliases for all aggregations first. As of this commit, it is only available on `count`
325390
// it('supports nested aliases', function(){
326391
// return u.then(function(u){

universe.js

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

universe.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)