@@ -5,11 +5,23 @@ import LRUCache from 'lru-cache';
55import isDocker from 'is-docker' ;
66import pLimit from 'p-limit' ;
77
8- import { ApiGateway , ApiGatewayOptions , UserBackgroundContext } from '@cubejs-backend/api-gateway' ;
8+ import {
9+ ApiGateway ,
10+ ApiGatewayOptions ,
11+ UserBackgroundContext
12+ } from '@cubejs-backend/api-gateway' ;
913import {
1014 CancelableInterval ,
11- createCancelableInterval , formatDuration , getAnonymousId ,
12- getEnv , assertDataSource , getRealType , internalExceptions , track , FileRepository , SchemaFileRepository ,
15+ createCancelableInterval ,
16+ formatDuration ,
17+ getAnonymousId ,
18+ getEnv ,
19+ assertDataSource ,
20+ getRealType ,
21+ internalExceptions ,
22+ track ,
23+ FileRepository ,
24+ SchemaFileRepository ,
1325} from '@cubejs-backend/shared' ;
1426
1527import type { Application as ExpressApplication } from 'express' ;
@@ -46,8 +58,15 @@ import type {
4658 DriverContext ,
4759 LoggerFn ,
4860 DriverConfig ,
61+ ScheduledRefreshTimeZonesFn ,
62+ } from './types' ;
63+ import {
64+ ContextToOrchestratorIdFn ,
65+ ContextAcceptanceResult ,
66+ ContextAcceptanceResultHttp ,
67+ ContextAcceptanceResultWs ,
68+ ContextAcceptor
4969} from './types' ;
50- import { ContextToOrchestratorIdFn , ContextAcceptanceResult , ContextAcceptanceResultHttp , ContextAcceptanceResultWs , ContextAcceptor } from './types' ;
5170
5271const { version } = require ( '../../../package.json' ) ;
5372
@@ -119,6 +138,8 @@ export class CubejsServerCore {
119138
120139 protected readonly preAggregationsSchema : PreAggregationsSchemaFn ;
121140
141+ protected readonly scheduledRefreshTimeZones : ScheduledRefreshTimeZonesFn ;
142+
122143 protected readonly orchestratorOptions : OrchestratorOptionsFn ;
123144
124145 public logger : LoggerFn ;
@@ -173,6 +194,7 @@ export class CubejsServerCore {
173194 this . contextToExternalDbType = wrapToFnIfNeeded ( this . options . externalDbType ) ;
174195 this . preAggregationsSchema = wrapToFnIfNeeded ( this . options . preAggregationsSchema ) ;
175196 this . orchestratorOptions = wrapToFnIfNeeded ( this . options . orchestratorOptions ) ;
197+ this . scheduledRefreshTimeZones = wrapToFnIfNeeded ( this . options . scheduledRefreshTimeZones || [ ] ) ;
176198
177199 this . compilerCache = new LRUCache < string , CompilerApi > ( {
178200 max : this . options . compilerCacheSize || 250 ,
@@ -453,7 +475,7 @@ export class CubejsServerCore {
453475 jwt : this . options . jwt ,
454476 refreshScheduler : this . getRefreshScheduler . bind ( this ) ,
455477 scheduledRefreshContexts : this . options . scheduledRefreshContexts ,
456- scheduledRefreshTimeZones : this . options . scheduledRefreshTimeZones ,
478+ scheduledRefreshTimeZones : this . scheduledRefreshTimeZones ,
457479 serverCoreVersion : this . coreServerVersion ,
458480 contextToApiScopes : this . options . contextToApiScopes ,
459481 gatewayPort : this . options . gatewayPort ,
@@ -700,7 +722,7 @@ export class CubejsServerCore {
700722 }
701723
702724 /**
703- * @internal Please dont use this method directly, use refreshTimer
725+ * @internal Please don't use this method directly, use refreshTimer
704726 */
705727 public handleScheduledRefreshInterval = async ( options ) => {
706728 const allContexts = await this . options . scheduledRefreshContexts ( ) ;
@@ -730,7 +752,10 @@ export class CubejsServerCore {
730752 concurrency : this . options . scheduledRefreshConcurrency ,
731753 } ;
732754
733- if ( this . options . scheduledRefreshTimeZones ) {
755+ const timezonesFromSecurityContext = await this . scheduledRefreshTimeZones ( context ) ;
756+ if ( timezonesFromSecurityContext . length > 0 ) {
757+ queryingOptions . timezones = timezonesFromSecurityContext ;
758+ } else if ( this . options . scheduledRefreshTimeZones ) {
734759 queryingOptions . timezones = this . options . scheduledRefreshTimeZones ;
735760 }
736761
@@ -746,7 +771,7 @@ export class CubejsServerCore {
746771 }
747772
748773 /**
749- * @internal Please dont use this method directly, use refreshTimer
774+ * @internal Please don't use this method directly, use refreshTimer
750775 */
751776 public async runScheduledRefresh ( context : UserBackgroundContext | null , queryingOptions ?: ScheduledRefreshOptions ) {
752777 return this . getRefreshScheduler ( ) . runScheduledRefresh (
0 commit comments