(tasks []*model.Task, taskMap map[string]*model.Task)
| 81 | } |
| 82 | |
| 83 | func findCriticalPathTasks(tasks []*model.Task, taskMap map[string]*model.Task) []reportTask { |
| 84 | cpIDs := calculateCriticalPathTasks(tasks, taskMap) |
| 85 | depthMap := calculateDepthMap(tasks, taskMap) |
| 86 | |
| 87 | var cpTasks []reportTask |
| 88 | for _, t := range tasks { |
| 89 | if cpIDs[t.ID] { |
| 90 | cpTasks = append(cpTasks, reportTask{ |
| 91 | ID: t.ID, |
| 92 | Title: t.Title, |
| 93 | Status: string(t.Status), |
| 94 | Priority: string(t.Priority), |
| 95 | Dependencies: t.Dependencies, |
| 96 | }) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Sort by depth ascending so the chain reads from root to leaf. |
| 101 | sort.Slice(cpTasks, func(i, j int) bool { |
| 102 | di := depthMap[cpTasks[i].ID] |
| 103 | dj := depthMap[cpTasks[j].ID] |
| 104 | if di != dj { |
| 105 | return di < dj |
| 106 | } |
| 107 | return cpTasks[i].ID < cpTasks[j].ID |
| 108 | }) |
| 109 | |
| 110 | return cpTasks |
| 111 | } |
no test coverage detected