Skip to content

Commit c4a9724

Browse files
committed
Revert "remove unused props (from, to)"
This reverts commit ebb1409. # Conflicts: # packages/cubejs-schema-compiler/src/compiler/JoinGraph.ts
1 parent a15ceda commit c4a9724

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

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

1111
type JoinEdge = {
1212
join: JoinDefinition,
13+
from: string,
14+
to: string,
1315
originalFrom: string,
1416
originalTo: string,
1517
};
@@ -78,9 +80,9 @@ export class JoinGraph implements CompilerInterface {
7880
this.nodes = R.compose(
7981
// This requires @types/[email protected] or newer
8082
// @ts-ignore
81-
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.originalTo, 1]))),
83+
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.to, 1]))),
8284
// @ts-ignore
83-
R.groupBy((join: JoinEdge) => join.originalFrom),
85+
R.groupBy((join: JoinEdge) => join.from),
8486
R.map(v => v[1]),
8587
R.toPairs
8688
// @ts-ignore
@@ -89,12 +91,12 @@ export class JoinGraph implements CompilerInterface {
8991
// @ts-ignore
9092
this.undirectedNodes = R.compose(
9193
// @ts-ignore
92-
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.originalFrom, 1]))),
94+
R.map(groupedByFrom => R.fromPairs(groupedByFrom.map(join => [join.from, 1]))),
9395
// @ts-ignore
94-
R.groupBy(join => join.originalTo),
96+
R.groupBy(join => join.to),
9597
R.unnest,
9698
// @ts-ignore
97-
R.map(v => [v[1], { originalFrom: v[1].originalTo, originalTo: v[1].originalFrom }]),
99+
R.map(v => [v[1], { from: v[1].to, to: v[1].from }]),
98100
R.toPairs
99101
// @ts-ignore
100102
)(this.edges);
@@ -142,6 +144,8 @@ export class JoinGraph implements CompilerInterface {
142144
.map(join => {
143145
const joinEdge: JoinEdge = {
144146
join,
147+
from: cube.name,
148+
to: join.name,
145149
originalFrom: cube.name,
146150
originalTo: join.name
147151
};
@@ -286,9 +290,9 @@ export class JoinGraph implements CompilerInterface {
286290
}
287291
visited[currentCube] = true;
288292
function nextNode(nextJoin: JoinEdge): string {
289-
return nextJoin.originalFrom === currentCube ? nextJoin.originalTo : nextJoin.originalFrom;
293+
return nextJoin.from === currentCube ? nextJoin.to : nextJoin.from;
290294
}
291-
const nextJoins = joins.filter(j => j.originalFrom === currentCube || j.originalTo === currentCube);
295+
const nextJoins = joins.filter(j => j.from === currentCube || j.to === currentCube);
292296
if (nextJoins.find(
293297
nextJoin => self.checkIfCubeMultiplied(currentCube, nextJoin) && !visited[nextNode(nextJoin)]
294298
)) {
@@ -302,8 +306,8 @@ export class JoinGraph implements CompilerInterface {
302306
}
303307

304308
protected checkIfCubeMultiplied(cube: string, join: JoinEdge): boolean {
305-
return join.originalFrom === cube && join.join.relationship === 'hasMany' ||
306-
join.originalTo === cube && join.join.relationship === 'belongsTo';
309+
return join.from === cube && join.join.relationship === 'hasMany' ||
310+
join.to === cube && join.join.relationship === 'belongsTo';
307311
}
308312

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

0 commit comments

Comments
 (0)