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

Function calculateCriticalPathTasks

apps/cli/internal/cli/snapshot_analysis.go:134–158  ·  view source on GitHub ↗

calculateCriticalPathTasks identifies tasks on the critical path

(tasks []*model.Task, taskMap map[string]*model.Task)

Source from the content-addressed store, hash-verified

132
133// calculateCriticalPathTasks identifies tasks on the critical path
134func calculateCriticalPathTasks(tasks []*model.Task, taskMap map[string]*model.Task) map[string]bool {
135 criticalPath := make(map[string]bool)
136
137 // Calculate depth for each task
138 depthMap := calculateDepthMap(tasks, taskMap)
139
140 // Find maximum depth
141 maxDepth := 0
142 for _, depth := range depthMap {
143 if depth > maxDepth {
144 maxDepth = depth
145 }
146 }
147
148 // Mark tasks on critical path (those with max depth)
149 for taskID, depth := range depthMap {
150 if depth == maxDepth {
151 criticalPath[taskID] = true
152 // Mark all dependencies on the path
153 markCriticalPathDependencies(taskID, taskMap, depthMap, maxDepth, criticalPath)
154 }
155 }
156
157 return criticalPath
158}
159
160// markCriticalPathDependencies recursively marks dependencies on critical path
161func markCriticalPathDependencies(

Callers 4

findCriticalPathTasksFunction · 0.85
runSnapshotFunction · 0.85

Calls 2

calculateDepthMapFunction · 0.70

Tested by 2