@cubejs-client/core
Advanced tools
Comparing version 0.9.11 to 0.9.12
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.9.12](https://github.com/statsbotco/cubejs-client/compare/v0.9.11...v0.9.12) (2019-06-03) | ||
### Bug Fixes | ||
* **client-core:** Update normalizePivotConfig method to not to fail if x or y are missing ([ee20863](https://github.com/statsbotco/cubejs-client/commit/ee20863)), closes [#10](https://github.com/statsbotco/cubejs-client/issues/10) | ||
## [0.9.11](https://github.com/statsbotco/cubejs-client/compare/v0.9.10...v0.9.11) (2019-05-31) | ||
@@ -8,0 +19,0 @@ |
@@ -18,2 +18,3 @@ import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import 'core-js/modules/es6.array.reduce'; | ||
import 'core-js/modules/es6.array.index-of'; | ||
import 'core-js/modules/es6.array.find'; | ||
@@ -147,2 +148,11 @@ import 'core-js/modules/es6.array.filter'; | ||
}); | ||
pivotConfig.x = pivotConfig.x || []; | ||
pivotConfig.y = pivotConfig.y || []; | ||
var allIncludedDimensions = pivotConfig.x.concat(pivotConfig.y); | ||
var allDimensions = timeDimensions.map(function (td) { | ||
return td.dimension; | ||
}).concat(query.dimensions); | ||
pivotConfig.x = pivotConfig.x.concat(allDimensions.filter(function (d) { | ||
return allIncludedDimensions.indexOf(d) === -1; | ||
})); | ||
@@ -256,3 +266,4 @@ if (!pivotConfig.x.concat(pivotConfig.y).find(function (d) { | ||
return unnest(rows.filter(function (_ref8) { | ||
return unnest( // collect Y values only from filled rows | ||
rows.filter(function (_ref8) { | ||
var row = _ref8.row; | ||
@@ -259,0 +270,0 @@ return Object.keys(row).length > 0; |
@@ -22,2 +22,3 @@ 'use strict'; | ||
require('core-js/modules/es6.array.reduce'); | ||
require('core-js/modules/es6.array.index-of'); | ||
require('core-js/modules/es6.array.find'); | ||
@@ -151,2 +152,11 @@ require('core-js/modules/es6.array.filter'); | ||
}); | ||
pivotConfig.x = pivotConfig.x || []; | ||
pivotConfig.y = pivotConfig.y || []; | ||
var allIncludedDimensions = pivotConfig.x.concat(pivotConfig.y); | ||
var allDimensions = timeDimensions.map(function (td) { | ||
return td.dimension; | ||
}).concat(query.dimensions); | ||
pivotConfig.x = pivotConfig.x.concat(allDimensions.filter(function (d) { | ||
return allIncludedDimensions.indexOf(d) === -1; | ||
})); | ||
@@ -260,3 +270,4 @@ if (!pivotConfig.x.concat(pivotConfig.y).find(function (d) { | ||
return ramda.unnest(rows.filter(function (_ref8) { | ||
return ramda.unnest( // collect Y values only from filled rows | ||
rows.filter(function (_ref8) { | ||
var row = _ref8.row; | ||
@@ -263,0 +274,0 @@ return Object.keys(row).length > 0; |
{ | ||
"name": "@cubejs-client/core", | ||
"version": "0.9.11", | ||
"version": "0.9.12", | ||
"description": "cube.js client", | ||
@@ -29,3 +29,3 @@ "main": "dist/cubejs-client-core.js", | ||
}, | ||
"gitHead": "1740bc8c83954bf8cc9b7c7dccb61870cf47f6aa" | ||
"gitHead": "2b55e74ce020c3e9d6e0396e6d9b1973c2966d03" | ||
} |
@@ -69,2 +69,7 @@ import { | ||
}); | ||
pivotConfig.x = pivotConfig.x || []; | ||
pivotConfig.y = pivotConfig.y || []; | ||
const allIncludedDimensions = pivotConfig.x.concat(pivotConfig.y); | ||
const allDimensions = timeDimensions.map(td => td.dimension).concat(query.dimensions); | ||
pivotConfig.x = pivotConfig.x.concat(allDimensions.filter(d => allIncludedDimensions.indexOf(d) === -1)); | ||
if (!pivotConfig.x.concat(pivotConfig.y).find(d => d === 'measures')) { | ||
@@ -71,0 +76,0 @@ pivotConfig.y = pivotConfig.y.concat(['measures']); |
@@ -0,1 +1,2 @@ | ||
/* globals jest,describe,test,expect */ | ||
import ResultSet from './ResultSet'; | ||
@@ -9,3 +10,3 @@ | ||
extendMoment: () => moment | ||
} | ||
}; | ||
}); | ||
@@ -21,17 +22,18 @@ | ||
timeDimension: 'Events.time' | ||
} | ||
const output = | ||
[ '2015-01-01T00:00:00.000', | ||
'2015-02-01T00:00:00.000', | ||
'2015-03-01T00:00:00.000', | ||
'2015-04-01T00:00:00.000', | ||
'2015-05-01T00:00:00.000', | ||
'2015-06-01T00:00:00.000', | ||
'2015-07-01T00:00:00.000', | ||
'2015-08-01T00:00:00.000', | ||
'2015-09-01T00:00:00.000', | ||
'2015-10-01T00:00:00.000', | ||
'2015-11-01T00:00:00.000', | ||
'2015-12-01T00:00:00.000' ] | ||
expect(resultSet.timeSeries(timeDimension)).toEqual(output) | ||
}; | ||
const output = [ | ||
'2015-01-01T00:00:00.000', | ||
'2015-02-01T00:00:00.000', | ||
'2015-03-01T00:00:00.000', | ||
'2015-04-01T00:00:00.000', | ||
'2015-05-01T00:00:00.000', | ||
'2015-06-01T00:00:00.000', | ||
'2015-07-01T00:00:00.000', | ||
'2015-08-01T00:00:00.000', | ||
'2015-09-01T00:00:00.000', | ||
'2015-10-01T00:00:00.000', | ||
'2015-11-01T00:00:00.000', | ||
'2015-12-01T00:00:00.000' | ||
]; | ||
expect(resultSet.timeSeries(timeDimension)).toEqual(output); | ||
}); | ||
@@ -45,32 +47,52 @@ | ||
timeDimension: 'Events.time' | ||
} | ||
const output = | ||
[ '2015-01-01T00:00:00.000', | ||
'2015-01-01T01:00:00.000', | ||
'2015-01-01T02:00:00.000', | ||
'2015-01-01T03:00:00.000', | ||
'2015-01-01T04:00:00.000', | ||
'2015-01-01T05:00:00.000', | ||
'2015-01-01T06:00:00.000', | ||
'2015-01-01T07:00:00.000', | ||
'2015-01-01T08:00:00.000', | ||
'2015-01-01T09:00:00.000', | ||
'2015-01-01T10:00:00.000', | ||
'2015-01-01T11:00:00.000', | ||
'2015-01-01T12:00:00.000', | ||
'2015-01-01T13:00:00.000', | ||
'2015-01-01T14:00:00.000', | ||
'2015-01-01T15:00:00.000', | ||
'2015-01-01T16:00:00.000', | ||
'2015-01-01T17:00:00.000', | ||
'2015-01-01T18:00:00.000', | ||
'2015-01-01T19:00:00.000', | ||
'2015-01-01T20:00:00.000', | ||
'2015-01-01T21:00:00.000', | ||
'2015-01-01T22:00:00.000', | ||
'2015-01-01T23:00:00.000' ] | ||
expect(resultSet.timeSeries(timeDimension)).toEqual(output) | ||
}; | ||
const output = [ | ||
'2015-01-01T00:00:00.000', | ||
'2015-01-01T01:00:00.000', | ||
'2015-01-01T02:00:00.000', | ||
'2015-01-01T03:00:00.000', | ||
'2015-01-01T04:00:00.000', | ||
'2015-01-01T05:00:00.000', | ||
'2015-01-01T06:00:00.000', | ||
'2015-01-01T07:00:00.000', | ||
'2015-01-01T08:00:00.000', | ||
'2015-01-01T09:00:00.000', | ||
'2015-01-01T10:00:00.000', | ||
'2015-01-01T11:00:00.000', | ||
'2015-01-01T12:00:00.000', | ||
'2015-01-01T13:00:00.000', | ||
'2015-01-01T14:00:00.000', | ||
'2015-01-01T15:00:00.000', | ||
'2015-01-01T16:00:00.000', | ||
'2015-01-01T17:00:00.000', | ||
'2015-01-01T18:00:00.000', | ||
'2015-01-01T19:00:00.000', | ||
'2015-01-01T20:00:00.000', | ||
'2015-01-01T21:00:00.000', | ||
'2015-01-01T22:00:00.000', | ||
'2015-01-01T23:00:00.000' | ||
]; | ||
expect(resultSet.timeSeries(timeDimension)).toEqual(output); | ||
}); | ||
}); | ||
describe('normalizePivotConfig', () => { | ||
test('fills missing x, y', () => { | ||
const resultSet = new ResultSet({ | ||
query: { | ||
dimensions: ['Foo.bar'], | ||
timeDimensions: [{ | ||
granularity: 'day', | ||
dimension: 'Foo.createdAt' | ||
}] | ||
} | ||
}); | ||
expect(resultSet.normalizePivotConfig({ y: ['Foo.bar'] })).toEqual({ | ||
x: ['Foo.createdAt'], | ||
y: ['Foo.bar', 'measures'], | ||
fillMissingDates: true | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
521177
14470