groupSnapshots groups snapshots by a field
(snapshots []TaskSnapshot, groupBy string)
| 24 | |
| 25 | // groupSnapshots groups snapshots by a field |
| 26 | func groupSnapshots(snapshots []TaskSnapshot, groupBy string) map[string][]TaskSnapshot { |
| 27 | groups := make(map[string][]TaskSnapshot) |
| 28 | |
| 29 | for _, snapshot := range snapshots { |
| 30 | var key string |
| 31 | switch groupBy { |
| 32 | case "status": |
| 33 | key = snapshot.Status |
| 34 | case "priority": |
| 35 | key = snapshot.Priority |
| 36 | case "effort": |
| 37 | key = snapshot.Effort |
| 38 | case "group": |
| 39 | key = snapshot.Group |
| 40 | default: |
| 41 | key = "ungrouped" |
| 42 | } |
| 43 | |
| 44 | if key == "" { |
| 45 | key = "none" |
| 46 | } |
| 47 | |
| 48 | groups[key] = append(groups[key], snapshot) |
| 49 | } |
| 50 | |
| 51 | return groups |
| 52 | } |
| 53 | |
| 54 | // calculateDepthMap calculates dependency depth for each task |
| 55 | func calculateDepthMap(tasks []*model.Task, taskMap map[string]*model.Task) map[string]int { |
no outgoing calls