Skip to content

Commit ebb1409

Browse files
committed
remove unused props (from, to)
1 parent aa7f2be commit ebb1409

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { CompilerInterface } from './PrepareCompiler';
1010

1111
type JoinEdge = {
1212
join: JoinDefinition,
13-
from: string,
14-
to: string,
1513
originalFrom: string,
1614
originalTo: string,
1715
};
@@ -86,8 +84,8 @@ export class JoinGraph implements CompilerInterface {
8684
>(
8785
// This requires @types/[email protected] or newer
8886
// @ts-ignore
89-
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.to, 1]))),
90-
R.groupBy((join: JoinEdge) => join.from),
87+
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.originalTo, 1]))),
88+
R.groupBy((join: JoinEdge) => join.originalFrom),
9189
R.map(v => v[1]),
9290
R.toPairs
9391
// @ts-ignore
@@ -96,12 +94,12 @@ export class JoinGraph implements CompilerInterface {
9694
// @ts-ignore
9795
this.undirectedNodes = R.compose(
9896
// @ts-ignore
99-
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.from, 1]))),
97+
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.originalFrom, 1]))),
10098
// @ts-ignore
101-
R.groupBy(join => join.to),
99+
R.groupBy(join => join.originalTo),
102100
R.unnest,
103101
// @ts-ignore
104-
R.map(v => [v[1], { from: v[1].to, to: v[1].from }]),
102+
R.map(v => [v[1], { originalFrom: v[1].originalTo, originalTo: v[1].originalFrom }]),
105103
R.toPairs
106104
// @ts-ignore
107105
)(this.edges);
@@ -149,8 +147,6 @@ export class JoinGraph implements CompilerInterface {
149147
.map(join => {
150148
const joinEdge: JoinEdge = {
151149
join,
152-
from: cube.name,
153-
to: join.name,
154150
originalFrom: cube.name,
155151
originalTo: join.name
156152
};
@@ -295,9 +291,9 @@ export class JoinGraph implements CompilerInterface {
295291
}
296292
visited[currentCube] = true;
297293
function nextNode(nextJoin: JoinEdge): string {
298-
return nextJoin.from === currentCube ? nextJoin.to : nextJoin.from;
294+
return nextJoin.originalFrom === currentCube ? nextJoin.originalTo : nextJoin.originalFrom;
299295
}
300-
const nextJoins = joins.filter(j => j.from === currentCube || j.to === currentCube);
296+
const nextJoins = joins.filter(j => j.originalFrom === currentCube || j.originalTo === currentCube);
301297
if (nextJoins.find(
302298
nextJoin => self.checkIfCubeMultiplied(currentCube, nextJoin) && !visited[nextNode(nextJoin)]
303299
)) {
@@ -311,8 +307,8 @@ export class JoinGraph implements CompilerInterface {
311307
}
312308

313309
protected checkIfCubeMultiplied(cube: string, join: JoinEdge): boolean {
314-
return join.from === cube && join.join.relationship === 'hasMany' ||
315-
join.to === cube && join.join.relationship === 'belongsTo';
310+
return join.originalFrom === cube && join.join.relationship === 'hasMany' ||
311+
join.originalTo === cube && join.join.relationship === 'belongsTo';
316312
}
317313

318314
protected joinsByPath(path: string[]): JoinEdge[] {

0 commit comments

Comments
 (0)