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

Commit

Permalink
Merge pull request #14 from crossfilter/fix-filtering-test-array-reduce
Browse files Browse the repository at this point in the history
Filtering tests and initial 0 for reduce
  • Loading branch information
tannerlinsley committed Mar 28, 2016
2 parents 22ee845 + 3b29036 commit 09c7b28
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "universe",
"version": "0.6.0",
"version": "0.6.1",
"description": "The fastest way to query and explore multivariate datasets",
"main": "src/universe.js",
"directories": {
Expand Down
4 changes: 2 additions & 2 deletions src/aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ function convertAggregatorString(keyString) {
function $sum(children) {
return children.reduce(function(a, b) {
return a + b
})
}, 0)
}

function $avg(children) {
return children.reduce(function(a, b) {
return a + b
}) / children.length
}, 0) / children.length
}

function $max(children) {
Expand Down
22 changes: 22 additions & 0 deletions test/postAggregation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ describe('universe postAggregation', function() {
})
})

it('works after filtering', function() {
var query
return u.then(function(u) {
return u.query({
groupBy: 'total',
})
})
.then(function(res) {
return res.changeMap({
count: true
})
})
.then(function(res) {
query = res
expect(res.data[0].value.countChangeFromEnd).to.equal(5)
return res.universe.filter('type', 'cash')
})
.then(function(){
expect(query.data[0].value.countChangeFromEnd).to.equal(0)
})
})

it('can sortByKey ascending and descending', function() {
return u.then(function(u) {
return u.query({
Expand Down
6 changes: 3 additions & 3 deletions universe.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion universe.min.js

Large diffs are not rendered by default.

0 comments on commit 09c7b28

Please sign in to comment.