Skip to content
Snippets Groups Projects
Commit 6c03cfd4 authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira
Browse files

Issue #38: Fix unrelated filters, using join

parent 69a6dc23
No related branches found
No related tags found
1 merge request!29Issue #38: Fix unrelated filters, using join
Pipeline #
......@@ -312,8 +312,8 @@ export class Graph {
const dimensions = q.dimensions;
const clauses = (q.clauses) ? q.clauses : [];
let output: View[] = [];
let verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
let verticesIds = this.verticesInQuery(q);
for (let i = 0; i < this.vertices.length; ++i) {
// Get the vertices and set their status and parent
this.vertices[i].state = State.UNVISITED;
......@@ -364,8 +364,7 @@ export class Graph {
// Recover the list of vertices
let dimToCover = dimensions.map((dim) => dim);
let metToCover = metrics.map((met) => met);
verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
verticesIds = this.verticesInQuery(q);
while (verticesIds.length > 0) {
// Choose a vertex and walks to his ancestors until
// reach the root, when walking this path choose
......@@ -538,4 +537,33 @@ export class Graph {
}
private verticesInQuery(q: Query): string[] {
const metrics = q.metrics;
const dimensions = q.dimensions;
const clauses = (q.clauses) ? q.clauses : [];
let verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
for (let i = 0; i < clauses.length; ++i) {
verticesIds = verticesIds.concat(clauses[i].filters.map((filter) => {
return filter.target.name;
}));
}
const sorted = verticesIds.sort();
if (sorted.length > 0) {
const unique = [sorted[0]];
for (let i = 1; i < sorted.length; ++i) {
if (sorted[i - 1] !== sorted[i]) {
unique.push(sorted[i]);
}
}
return unique;
}
else {
return [];
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment