@cubejs-backend/api-gateway
Advanced tools
Comparing version 0.11.18 to 0.11.20
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.11.20](https://github.com/cube-js/cube.js/compare/v0.11.19...v0.11.20) (2019-11-18) | ||
### Features | ||
* per cube `dataSource` support ([6dc3fef](https://github.com/cube-js/cube.js/commit/6dc3fef)) | ||
## [0.11.18](https://github.com/cube-js/cube.js/compare/v0.11.17...v0.11.18) (2019-11-09) | ||
@@ -8,0 +19,0 @@ |
31
index.js
@@ -44,24 +44,2 @@ const jwt = require('jsonwebtoken'); | ||
const prepareAliasToMemberNameMap = (metaConfig, sqlQuery, query) => { | ||
const configMap = toConfigMap(metaConfig); | ||
const lookupAlias = (memberType) => (member) => { | ||
const path = member.split('.'); | ||
const config = configMap[path[0]][memberType].find(m => m.name === member); | ||
if (!config) { | ||
return undefined; | ||
} | ||
return [config.aliasName, member]; | ||
}; | ||
return R.fromPairs( | ||
(query.measures || []).map(lookupAlias('measures')) | ||
.concat((query.dimensions || []).map(lookupAlias('dimensions'))) | ||
.concat((query.segments || []).map(lookupAlias('segments'))) | ||
.concat((query.timeDimensions || []).map(td => lookupAlias('dimensions')(td.dimension))) | ||
.concat(sqlQuery.timeDimensionAlias ? [[sqlQuery.timeDimensionAlias, sqlQuery.timeDimensionField]] : []) | ||
.filter(a => !!a) | ||
); | ||
}; | ||
const transformValue = (value, type) => { | ||
@@ -324,5 +302,4 @@ if (value && type === 'time') { | ||
const sqlQuery = compilerSqlResult; | ||
const metaConfig = metaConfigResult; | ||
const annotation = prepareAnnotation(metaConfig, normalizedQuery); | ||
const aliasToMemberNameMap = prepareAliasToMemberNameMap(metaConfig, sqlQuery, normalizedQuery); | ||
const annotation = prepareAnnotation(metaConfigResult, normalizedQuery); | ||
const aliasToMemberNameMap = sqlQuery.aliasNameToMember; | ||
const toExecute = { | ||
@@ -335,3 +312,5 @@ ...sqlQuery, | ||
}; | ||
const response = await this.getAdapterApi(context).executeQuery(toExecute); | ||
const response = await this.getAdapterApi({ | ||
...context, dataSource: sqlQuery.dataSource | ||
}).executeQuery(toExecute); | ||
this.log(context, { | ||
@@ -338,0 +317,0 @@ type: 'Load Request Success', |
@@ -5,3 +5,3 @@ { | ||
"author": "Statsbot, Inc.", | ||
"version": "0.11.18", | ||
"version": "0.11.20", | ||
"repository": { | ||
@@ -37,3 +37,3 @@ "type": "git", | ||
"license": "Apache-2.0", | ||
"gitHead": "ce40708f8012e5f6de475d74f4841501caa0d998" | ||
"gitHead": "79670a0942c4fe03db87ba63a5ba2f33fcbd7bd1" | ||
} |
46860
729