MCPcopy Create free account
hub / github.com/driangle/taskmd / findCriticalPathTasks

Function findCriticalPathTasks

apps/cli/internal/cli/report_collect.go:83–111  ·  view source on GitHub ↗
(tasks []*model.Task, taskMap map[string]*model.Task)

Source from the content-addressed store, hash-verified

81}
82
83func 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}

Callers 1

collectReportDataFunction · 0.85

Calls 2

calculateDepthMapFunction · 0.70

Tested by

no test coverage detected