Skip to content

Commit 8ce7a15

Browse files
committed
code polish
1 parent a31d189 commit 8ce7a15

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 === '*') {
@@ -581,7 +581,7 @@ export class CubeSymbols {
581581

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

593-
const res = cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
593+
return cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
594594
const resolvedSymbol = this.resolveSymbol(cube, name);
595595
if (resolvedSymbol) {
596596
return resolvedSymbol;
@@ -603,8 +603,6 @@ export class CubeSymbols {
603603
securityContext: context.securityContext,
604604
}
605605
});
606-
607-
return res;
608606
}
609607

610608
protected evaluateReferences<T extends ToString | Array<ToString>>(
@@ -739,15 +737,14 @@ export class CubeSymbols {
739737
}
740738

741739
protected depsContextSymbols() {
742-
return Object.assign({
740+
return {
743741
filterParams: this.filtersProxyDep(),
744742
filterGroup: this.filterGroupFunctionDep(),
745743
securityContext: BaseQuery.contextSymbolsProxyFrom({}, (param) => param),
746744
sqlUtils: {
747745
convertTz: (f) => f
748-
749746
},
750-
});
747+
};
751748
}
752749

753750
protected filtersProxyDep() {
@@ -792,7 +789,7 @@ export class CubeSymbols {
792789

793790
if (CONTEXT_SYMBOLS[name]) {
794791
// always resolves if contextSymbols aren't passed for transpile step
795-
const symbol = contextSymbols && contextSymbols[CONTEXT_SYMBOLS[name]] || {};
792+
const symbol = contextSymbols?.[CONTEXT_SYMBOLS[name]] || {};
796793
// eslint-disable-next-line no-underscore-dangle
797794
symbol._objectWithResolvedProperties = true;
798795
return symbol;
@@ -824,12 +821,12 @@ export class CubeSymbols {
824821
const parentIndex = currResolveIndexFn();
825822
cube = this.cubeDependenciesProxy(parentIndex, newCubeName);
826823
return cube;
827-
} else if (this.symbols[cubeName] && this.symbols[cubeName][name] && this.symbols[cubeName][name].type === 'time') {
824+
} else if (this.symbols[cubeName]?.[name] && this.symbols[cubeName][name].type === 'time') {
828825
const parentIndex = currResolveIndexFn();
829826
return this.timeDimDependenciesProxy(parentIndex);
830827
}
831828
}
832-
return cube || (this.symbols[cubeName] && this.symbols[cubeName][name]);
829+
return cube || this.symbols[cubeName]?.[name];
833830
}
834831

835832
protected cubeReferenceProxy(cubeName, joinHints?: any[], refProperty?: any) {
@@ -919,7 +916,7 @@ export class CubeSymbols {
919916
return { interval: `1 ${granName}` };
920917
}
921918

922-
return cube && cube[dimName] && cube[dimName][gr] && cube[dimName][gr][granName];
919+
return cube?.[dimName]?.[gr]?.[granName];
923920
}
924921

925922
protected cubeDependenciesProxy(parentIndex, cubeName) {

0 commit comments

Comments
 (0)