Skip to content

Commit c93ae12

Browse files
authored
fix: refreshKey is evaluated ten times more frequently if sql and every are simultaneously defined (cube-js#3873)
* fix: `refreshKey` is evaluated ten times more frequently if `sql` and `every` are simultaneously defined * chore: `refreshKey` is evaluated ten times more frequently if `sql` and `every` are simultaneously defined -- tests
1 parent 8ff7e4c commit c93ae12

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,23 +2311,23 @@ export class BaseQuery {
23112311
);
23122312
}
23132313

2314-
refreshKeyRenewalThresholdForInterval(refreshKey, limitedWithMax = true) {
2314+
refreshKeyRenewalThresholdForInterval(refreshKey, everyWithoutSql = true) {
23152315
const { every } = refreshKey;
23162316

23172317
if (/^(\d+) (second|minute|hour|day|week)s?$/.test(every)) {
2318-
const threshold = Math.max(Math.round(this.parseSecondDuration(every) / 10), 1);
2318+
const threshold = Math.max(Math.round(this.parseSecondDuration(every) / (everyWithoutSql ? 10 : 1)), 1);
23192319

2320-
if (limitedWithMax) {
2320+
if (everyWithoutSql) {
23212321
return Math.min(threshold, 300);
23222322
}
23232323

23242324
return threshold;
23252325
}
23262326

23272327
const { interval } = this.calcIntervalForCronString(refreshKey);
2328-
const threshold = Math.max(Math.round(interval / 10), 1);
2328+
const threshold = Math.max(Math.round(interval / (everyWithoutSql ? 10 : 1)), 1);
23292329

2330-
if (limitedWithMax) {
2330+
if (everyWithoutSql) {
23312331
return Math.min(threshold, 300);
23322332
}
23332333

packages/cubejs-schema-compiler/test/unit/base-query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ describe('SQL Generation', () => {
513513
[],
514514
{
515515
external: false,
516-
renewalThreshold: 720,
516+
renewalThreshold: 7200,
517517
}
518518
]
519519
]);
@@ -562,7 +562,7 @@ describe('SQL Generation', () => {
562562
{
563563
external: false,
564564
// 60 * 60 *2
565-
renewalThreshold: 720,
565+
renewalThreshold: 7200,
566566
}
567567
]
568568
]);

0 commit comments

Comments
 (0)