New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cubejs-backend/query-orchestrator

Package Overview
Dependencies
Maintainers
2
Versions
509
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cubejs-backend/query-orchestrator - npm Package Compare versions

Comparing version 0.11.18 to 0.12.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.12.0](https://github.com/cube-js/cube.js/compare/v0.11.25...v0.12.0) (2019-11-25)
### Features
* Show `refreshKey` values in Playground ([b49e184](https://github.com/cube-js/cube.js/commit/b49e184))
## [0.11.18](https://github.com/cube-js/cube.js/compare/v0.11.17...v0.11.18) (2019-11-09)

@@ -8,0 +19,0 @@

84

orchestrator/QueryCache.js

@@ -19,5 +19,6 @@ const crypto = require('crypto');

cachedQueryResult (queryBody, preAggregationsTablesToTempTables) {
const replacePreAggregationTableNames = (queryAndParams) =>
QueryCache.replacePreAggregationTableNames(queryAndParams, preAggregationsTablesToTempTables);
async cachedQueryResult(queryBody, preAggregationsTablesToTempTables) {
const replacePreAggregationTableNames = (queryAndParams) => QueryCache.replacePreAggregationTableNames(
queryAndParams, preAggregationsTablesToTempTables
);

@@ -27,6 +28,7 @@ const query = replacePreAggregationTableNames(queryBody.query);

if (Number.isInteger(queryBody.queuePriority)) {
// eslint-disable-next-line prefer-destructuring
queuePriority = queryBody.queuePriority;
}
const forceNoCache = queryBody.forceNoCache || false;
const values = queryBody.values;
const { values } = queryBody;
const cacheKeyQueries =

@@ -44,3 +46,3 @@ (

if (!cacheKeyQueries) {
return this.queryWithRetryAndRelease(query, values, queryBody.external);
return { data: await this.queryWithRetryAndRelease(query, values, queryBody.external) };
}

@@ -73,3 +75,6 @@ const cacheKey = QueryCache.queryCacheKey(queryBody);

return mainPromise;
return {
data: await mainPromise,
lastRefreshTime: await this.lastRefreshTime(cacheKey)
};
}

@@ -82,5 +87,5 @@

static replaceAll(replaceThis, withThis, inThis) {
withThis = withThis.replace(/\$/g,"$$$$");
withThis = withThis.replace(/\$/g, "$$$$");
return inThis.replace(
new RegExp(replaceThis.replace(/([/,!\\^${}[\]().*+?|<>\-&])/g,"\\$&"),"g"),
new RegExp(replaceThis.replace(/([/,!\\^${}[\]().*+?|<>\-&])/g, "\\$&"), "g"),
withThis

@@ -90,3 +95,3 @@ );

static replacePreAggregationTableNames (queryAndParams, preAggregationsTablesToTempTables) {
static replacePreAggregationTableNames(queryAndParams, preAggregationsTablesToTempTables) {
const [keyQuery, params] = Array.isArray(queryAndParams) ? queryAndParams : [queryAndParams, []];

@@ -178,5 +183,5 @@ const replacedKeqQuery = preAggregationsTablesToTempTables.reduce(

if (!(e instanceof ContinueWaitError)) {
this.logger('Error while renew cycle', { query, query_values: values, error: e.stack || e })
this.logger('Error while renew cycle', { query, query_values: values, error: e.stack || e });
}
})
});
}

@@ -202,17 +207,21 @@

})
.then(cacheKeyQueryResults => {
return this.cacheQueryResult(
query, values,
cacheKey,
expireSecs,
{
renewalThreshold: renewalThreshold || 6 * 60 * 60,
renewalKey: cacheKeyQueryResults && [
cacheKeyQueries, cacheKeyQueryResults, this.queryRedisKey([query, values])
],
waitForRenew: true,
external: options.external
}
);
});
.then(async cacheKeyQueryResults => (
{
data: await this.cacheQueryResult(
query, values,
cacheKey,
expireSecs,
{
renewalThreshold: renewalThreshold || 6 * 60 * 60,
renewalKey: cacheKeyQueryResults && [
cacheKeyQueries, cacheKeyQueryResults, this.queryRedisKey([query, values])
],
waitForRenew: true,
external: options.external
}
),
refreshKeyValues: cacheKeyQueryResults,
lastRefreshTime: await this.lastRefreshTime(cacheKey)
}
));
}

@@ -222,7 +231,7 @@

options = options || {};
const renewalThreshold = options.renewalThreshold;
const { renewalThreshold } = options;
const renewalKey = options.renewalKey && this.queryRedisKey(options.renewalKey);
const redisKey = this.queryRedisKey(cacheKey);
const fetchNew = () => {
return this.queryWithRetryAndRelease(query, values, options.priority, cacheKey, options.external).then(res => {
const fetchNew = () => (
this.queryWithRetryAndRelease(query, values, options.priority, cacheKey, options.external).then(res => {
const result = {

@@ -236,3 +245,3 @@ time: (new Date()).getTime(),

this.logger('Renewed', { cacheKey });
return res
return res;
});

@@ -243,7 +252,7 @@ }).catch(e => {

this.cacheDriver.remove(redisKey)
.catch(e => this.logger('Error removing key', { cacheKey, error: e.stack || e }));
.catch(err => this.logger('Error removing key', { cacheKey, error: err.stack || err }));
}
throw e;
});
};
})
);

@@ -282,3 +291,3 @@ if (options.forceNoCache) {

if (!(e instanceof ContinueWaitError)) {
this.logger('Error renewing', {cacheKey, error: e.stack || e})
this.logger('Error renewing', { cacheKey, error: e.stack || e });
}

@@ -297,4 +306,9 @@ });

async lastRefreshTime(cacheKey) {
const cachedValue = await this.cacheDriver.get(this.queryRedisKey(cacheKey));
return cachedValue && new Date(cachedValue.time);
}
queryRedisKey(cacheKey) {
return `SQL_QUERY_RESULT_${this.redisPrefix}_${crypto.createHash('md5').update(JSON.stringify(cacheKey)).digest("hex")}`
return `SQL_QUERY_RESULT_${this.redisPrefix}_${crypto.createHash('md5').update(JSON.stringify(cacheKey)).digest("hex")}`;
}

@@ -301,0 +315,0 @@ }

@@ -5,3 +5,3 @@ {

"author": "Statsbot, Inc.",
"version": "0.11.18",
"version": "0.12.0",
"repository": {

@@ -29,3 +29,3 @@ "type": "git",

"license": "Apache-2.0",
"gitHead": "ce40708f8012e5f6de475d74f4841501caa0d998"
"gitHead": "1e19567b8451359f9238f6efb8da1f2601bb06d8"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc