( ctx context.Context, record Task, depthByID map[string]int, childCountByID map[string]int, )
| 181 | } |
| 182 | |
| 183 | func (m *Service) buildTreeNode( |
| 184 | ctx context.Context, |
| 185 | record Task, |
| 186 | depthByID map[string]int, |
| 187 | childCountByID map[string]int, |
| 188 | ) (TreeNode, error) { |
| 189 | if strings.TrimSpace(record.ParentTaskID) != "" { |
| 190 | depthByID[record.ID] = depthByID[record.ParentTaskID] + 1 |
| 191 | } |
| 192 | |
| 193 | dependencies, err := m.store.ListDependencies(ctx, record.ID) |
| 194 | if err != nil { |
| 195 | return TreeNode{}, err |
| 196 | } |
| 197 | runs, err := m.store.ListTaskRuns(ctx, RunQuery{TaskID: record.ID}) |
| 198 | if err != nil { |
| 199 | return TreeNode{}, err |
| 200 | } |
| 201 | events, err := m.store.ListTaskEvents(ctx, EventQuery{TaskID: record.ID, Limit: 1}) |
| 202 | if err != nil { |
| 203 | return TreeNode{}, err |
| 204 | } |
| 205 | summary, err := m.enrichTaskSummaryFromState(ctx, record, childCountByID[record.ID], dependencies, runs, events) |
| 206 | if err != nil { |
| 207 | return TreeNode{}, err |
| 208 | } |
| 209 | |
| 210 | return TreeNode{ |
| 211 | Task: taskReferenceFromTask(record, summary.Status), |
| 212 | ParentTaskID: record.ParentTaskID, |
| 213 | Depth: depthByID[record.ID], |
| 214 | ChildCount: childCountByID[record.ID], |
| 215 | ActiveRun: summary.ActiveRun, |
| 216 | LastActivityAt: summary.LastActivityAt, |
| 217 | }, nil |
| 218 | } |
| 219 | |
| 220 | func splitTreeView(rootTaskID string, nodes []TreeNode) TreeView { |
| 221 | rootIndex := 0 |
no test coverage detected