I wrote a custom function to calculate per project critical paths and save the critical path status as well as the slack. When running the function using the ‘onAfterAutoSchedule’ event i’m getting very different performance when the ‘onAfterAutoSchedule’ is triggered by closing an inline editor vs after dragging the task. On the same task making the same change using drag and drop the execution time is ~100ms while using inline editor is ~2000ms. Looking at the performance tab in chrome it seems like the issue comes from the updates to the data processor. Do these two events handle updates differently?
Here is the code I am using to update the tasks
gantt.batchUpdate(() => {
gantt.getTaskBy('project_id', projectId, { task: true, project: true }).forEach((task) => {
let shouldUpdate = false;
if (Boolean(task.critical_path) !== Boolean(criticalTasks[task.id])) {
task.critical_path = Boolean(criticalTasks[task.id]);
shouldUpdate = true;
}
if (Object.hasOwn(taskSlack, task.id)) {
if (taskSlack[task.id].freeSlack !== task.free_slack) {
task.free_slack = taskSlack[task.id].freeSlack;
shouldUpdate = true;
}
if (taskSlack[task.id].totalSlack !== task.total_slack) {
task.total_slack = taskSlack[task.id].totalSlack;
shouldUpdate = true;
}
}
if (shouldUpdate) {
gantt.updateTask(task.id);
}
});
}, true);