Skip to content

Commit

Permalink
fix(qseow): Sort task tree by task name on each level in `qseow task-…
Browse files Browse the repository at this point in the history
…get` command

Fixes #592
  • Loading branch information
mountaindude committed Jan 4, 2025
1 parent a1bf796 commit 5821e73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/task/get_task_sub_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function extGetTaskSubTree(_, task, parentTreeLevel, parentTask, logger)
}
}

// Now that all downstream tasks have been retrieved, we can check if there are any general issues with those tasks
// Now that all downstream tasks have been retrieved, we can check if there are any issues with those tasks.
// Examples are cyclic task tree relationships, multiple downstream tasks with the same ID etc.

// Check for downstream tasks with the same ID and same relationship with parent task (e.g. on-success or on-failure)
Expand Down Expand Up @@ -138,6 +138,9 @@ export function extGetTaskSubTree(_, task, parentTreeLevel, parentTask, logger)
return validDownstreamTasks.find((a) => a.downstreamTask.id === id);
});

// Now sort the downstream tasks by task name
uniqueDownstreamTasks.sort((a, b) => a.downstreamTask.taskName.localeCompare(b.downstreamTask.taskName));

for (const uniqueDownstreamTask of uniqueDownstreamTasks) {
if (_.taskCyclicStack.has(uniqueDownstreamTask.downstreamTask.id)) {
// Cyclic dependency detected
Expand Down Expand Up @@ -298,7 +301,6 @@ export function extGetTaskSubTree(_, task, parentTreeLevel, parentTask, logger)
}

return subTree;
// console.log('subTree: ' + JSON.stringify(subTree));
} catch (err) {
catchLog('GET TASK SUBTREE (tree)', err);
return false;
Expand Down

0 comments on commit 5821e73

Please sign in to comment.