tasksgraphs: fix parent task row

* Consider all the tasks from the current level + 1 when fetching the parents
tasks

* Exclude the child level when computing the parent row needed to create an edge
that don't overlaps with the tasks of greater level.
This commit is contained in:
Simone Gotti 2019-08-29 12:08:42 +02:00
parent 5af7f6169d
commit b2955f1704
1 changed files with 19 additions and 2 deletions

View File

@ -205,12 +205,29 @@ export default {
return levelTasks; return levelTasks;
}; };
let levelsTasks = function(tasks, startLevel) {
let levelTasks = [];
for (let task of tasks) {
if (task.level < startLevel) {
continue;
}
levelTasks.push(task);
}
return levelTasks;
};
let levelTasksByRow = function(tasks, level) { let levelTasksByRow = function(tasks, level) {
return levelTasks(tasks, level).sort((a, b) => return levelTasks(tasks, level).sort((a, b) =>
a.row > b.row ? 1 : b.row > a.row ? -1 : 0 a.row > b.row ? 1 : b.row > a.row ? -1 : 0
); );
}; };
let levelsTasksByRow = function(tasks, startLevel) {
return levelsTasks(tasks, startLevel).sort((a, b) =>
a.row > b.row ? 1 : b.row > a.row ? -1 : 0
);
};
let levelFreeRow = function(tasks, level) { let levelFreeRow = function(tasks, level) {
let rows = []; let rows = [];
for (let task of tasks) { for (let task of tasks) {
@ -254,7 +271,7 @@ export default {
let row = 0; let row = 0;
// if not at the last level fetch parents by their childs // if not at the last level fetch parents by their childs
if (l < maxlevel) { if (l < maxlevel) {
for (let curTask of levelTasksByRow(graphTasks, l + 1)) { for (let curTask of levelsTasksByRow(graphTasks, l + 1)) {
for (let depTaskID in curTask.depends) { for (let depTaskID in curTask.depends) {
for (let parent of levelTasks(graphTasks, l)) { for (let parent of levelTasks(graphTasks, l)) {
if (seenTasks.has(parent.id)) { if (seenTasks.has(parent.id)) {
@ -266,7 +283,7 @@ export default {
let maxChildLevel = taskMaxChildLevel(graphTasks, parent); let maxChildLevel = taskMaxChildLevel(graphTasks, parent);
if (maxChildLevel > parent.level + 1) { if (maxChildLevel > parent.level + 1) {
// put parent in a row greater than the max row the next levels until the child level // put parent in a row greater than the max row the next levels until the child level
let mrow = levelsMaxRow(graphTasks, maxChildLevel) + 1; let mrow = levelsMaxRow(graphTasks, maxChildLevel - 1) + 1;
parent.row = mrow; parent.row = mrow;
row = mrow + 1; row = mrow + 1;
} else { } else {