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

Function taskToSnapshot

apps/cli/internal/cli/snapshot.go:173–226  ·  view source on GitHub ↗

taskToSnapshot converts a model.Task to TaskSnapshot

(
	task *model.Task,
	coreOnly bool,
	includeDerived bool,
	depthMap map[string]int,
	topoOrder map[string]int,
	criticalPath map[string]bool,
	taskMap map[string]*model.Task,
)

Source from the content-addressed store, hash-verified

171
172// taskToSnapshot converts a model.Task to TaskSnapshot
173func taskToSnapshot(
174 task *model.Task,
175 coreOnly bool,
176 includeDerived bool,
177 depthMap map[string]int,
178 topoOrder map[string]int,
179 criticalPath map[string]bool,
180 taskMap map[string]*model.Task,
181) TaskSnapshot {
182 snapshot := TaskSnapshot{
183 ID: task.ID,
184 Title: task.Title,
185 }
186
187 // Add non-core fields unless --core is specified
188 if !coreOnly {
189 snapshot.Status = string(task.Status)
190 snapshot.Priority = string(task.Priority)
191 snapshot.Effort = string(task.Effort)
192 snapshot.Tags = task.Tags
193 snapshot.Group = task.Group
194 if !task.Created.IsZero() {
195 snapshot.Created = task.Created.Format("2006-01-02")
196 }
197 snapshot.FilePath = task.FilePath
198 }
199
200 // Always include dependencies
201 snapshot.Dependencies = task.Dependencies
202
203 // Add derived fields if requested
204 if includeDerived {
205 // Is blocked: has unmet dependencies
206 isBlocked := isTaskBlocked(task, taskMap)
207 snapshot.IsBlocked = &isBlocked
208
209 // Dependency depth
210 if depth, ok := depthMap[task.ID]; ok {
211 snapshot.DependencyDepth = &depth
212 }
213
214 // Topological order
215 if order, ok := topoOrder[task.ID]; ok {
216 snapshot.TopologicalOrder = &order
217 }
218
219 // On critical path
220 if onPath, ok := criticalPath[task.ID]; ok {
221 snapshot.OnCriticalPath = &onPath
222 }
223 }
224
225 return snapshot
226}

Callers 3

runSnapshotFunction · 0.85

Calls 1

isTaskBlockedFunction · 0.85

Tested by 2