Skip to content

Commit 5cc936f

Browse files
committed
code polish
1 parent d644d45 commit 5cc936f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeSymbols.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export class CubeSymbols {
440440
const cubeReference = split[split.length - 1];
441441
const cubeName = cubeInclude.alias || cubeReference;
442442

443-
let includes;
443+
let includes: any[];
444444
const fullMemberName = (memberName: string) => (cubeInclude.prefix ? `${cubeName}_${memberName}` : memberName);
445445

446446
if (cubeInclude.includes === '*') {
@@ -587,7 +587,7 @@ export class CubeSymbols {
587587

588588
/**
589589
* This method is mainly used for evaluating RLS conditions and filters.
590-
* It allows referencing security_context (lowecase) in dynamic conditions or filter values.
590+
* It allows referencing security_context (lowercase) in dynamic conditions or filter values.
591591
*
592592
* It currently does not support async calls because inner resolveSymbol and
593593
* resolveSymbolsCall are sync. Async support may be added later with deeper
@@ -596,7 +596,7 @@ export class CubeSymbols {
596596
protected evaluateContextFunction(cube: any, contextFn: any, context: any = {}) {
597597
const cubeEvaluator = this;
598598

599-
const res = cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
599+
return cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
600600
const resolvedSymbol = this.resolveSymbol(cube, name);
601601
if (resolvedSymbol) {
602602
return resolvedSymbol;
@@ -609,8 +609,6 @@ export class CubeSymbols {
609609
securityContext: context.securityContext,
610610
}
611611
});
612-
613-
return res;
614612
}
615613

616614
protected evaluateReferences<T extends ToString | Array<ToString>>(
@@ -766,15 +764,14 @@ export class CubeSymbols {
766764
}
767765

768766
protected depsContextSymbols() {
769-
return Object.assign({
767+
return {
770768
filterParams: this.filtersProxyDep(),
771769
filterGroup: this.filterGroupFunctionDep(),
772770
securityContext: CubeSymbols.contextSymbolsProxyFrom({}, (param) => param),
773771
sqlUtils: {
774772
convertTz: (f) => f
775-
776773
},
777-
});
774+
};
778775
}
779776

780777
protected filtersProxyDep() {
@@ -819,7 +816,7 @@ export class CubeSymbols {
819816

820817
if (CONTEXT_SYMBOLS[name]) {
821818
// always resolves if contextSymbols aren't passed for transpile step
822-
const symbol = contextSymbols && contextSymbols[CONTEXT_SYMBOLS[name]] || {};
819+
const symbol = contextSymbols?.[CONTEXT_SYMBOLS[name]] || {};
823820
// eslint-disable-next-line no-underscore-dangle
824821
symbol._objectWithResolvedProperties = true;
825822
return symbol;
@@ -851,12 +848,12 @@ export class CubeSymbols {
851848
const parentIndex = currResolveIndexFn();
852849
cube = this.cubeDependenciesProxy(parentIndex, newCubeName);
853850
return cube;
854-
} else if (this.symbols[cubeName] && this.symbols[cubeName][name] && this.symbols[cubeName][name].type === 'time') {
851+
} else if (this.symbols[cubeName]?.[name] && this.symbols[cubeName][name].type === 'time') {
855852
const parentIndex = currResolveIndexFn();
856853
return this.timeDimDependenciesProxy(parentIndex);
857854
}
858855
}
859-
return cube || (this.symbols[cubeName] && this.symbols[cubeName][name]);
856+
return cube || this.symbols[cubeName]?.[name];
860857
}
861858

862859
protected cubeReferenceProxy(cubeName, joinHints?: any[], refProperty?: any) {
@@ -946,7 +943,7 @@ export class CubeSymbols {
946943
return { interval: `1 ${granName}` };
947944
}
948945

949-
return cube && cube[dimName] && cube[dimName][gr] && cube[dimName][gr][granName];
946+
return cube?.[dimName]?.[gr]?.[granName];
950947
}
951948

952949
protected cubeDependenciesProxy(parentIndex, cubeName) {

0 commit comments

Comments
 (0)