|
7 | 7 | "sort" |
8 | 8 | "strconv" |
9 | 9 | "strings" |
10 | | - "time" |
11 | 10 |
|
12 | 11 | "github.com/charmbracelet/glamour" |
13 | 12 | "github.com/trickest/trickest-cli/cmd/execute" |
@@ -81,36 +80,14 @@ func generateHelpMarkdown(workflow *trickest.Workflow, labeledPrimitiveNodes []* |
81 | 80 | sb.WriteString(fmt.Sprintf("%s\n\n", workflow.Description)) |
82 | 81 | } |
83 | 82 |
|
84 | | - runStats := []struct { |
85 | | - date time.Time |
86 | | - machines int |
87 | | - duration time.Duration |
88 | | - url string |
89 | | - }{} |
90 | | - for _, run := range runs { |
91 | | - machines := run.Machines.Default |
92 | | - if machines == nil { |
93 | | - machines = run.Machines.SelfHosted |
94 | | - } |
95 | | - date := *run.StartedDate |
96 | | - duration := run.CompletedDate.Sub(date) |
97 | | - runURL := fmt.Sprintf("%s?run=%s", workflowURL, run.ID) |
98 | | - runStats = append(runStats, struct { |
99 | | - date time.Time |
100 | | - machines int |
101 | | - duration time.Duration |
102 | | - url string |
103 | | - }{date, *machines, duration, runURL}) |
104 | | - } |
105 | | - |
106 | 83 | machineCount := defaultMachineCount |
107 | 84 | if maxMachines > 0 && maxMachines < defaultMachineCount { |
108 | 85 | machineCount = maxMachines |
109 | | - } else if len(runStats) > 0 { |
| 86 | + } else if len(runs) > 0 { |
110 | 87 | highestMachineCount := 0 |
111 | | - for _, runStat := range runStats { |
112 | | - if runStat.machines > highestMachineCount { |
113 | | - highestMachineCount = runStat.machines |
| 88 | + for _, run := range runs { |
| 89 | + if run.Parallelism > highestMachineCount { |
| 90 | + highestMachineCount = run.Parallelism |
114 | 91 | } |
115 | 92 | } |
116 | 93 | machineCount = highestMachineCount |
@@ -185,20 +162,20 @@ func generateHelpMarkdown(workflow *trickest.Workflow, labeledPrimitiveNodes []* |
185 | 162 | } |
186 | 163 |
|
187 | 164 | // Past runs section |
188 | | - if len(runStats) > 0 { |
| 165 | + if len(runs) > 0 { |
189 | 166 | sb.WriteString("## Past Runs\n\n") |
190 | | - sb.WriteString("| Started at | Machines | Duration | URL |\n") |
191 | | - sb.WriteString("|------------|----------|----------|-----|\n") |
192 | | - for _, runStat := range runStats { |
193 | | - machines := runStat.machines |
194 | | - date := runStat.date.Format("2006-01-02 15:04") |
195 | | - duration := runStat.duration |
| 167 | + sb.WriteString("| Started at | Parallelism | Duration | URL |\n") |
| 168 | + sb.WriteString("|------------|-------------|----------|-----|\n") |
| 169 | + for _, run := range runs { |
| 170 | + machines := run.Parallelism |
| 171 | + date := run.StartedDate.Format("2006-01-02 15:04") |
| 172 | + duration := run.CompletedDate.Sub(*run.StartedDate) |
196 | 173 | durationStr := display.FormatDuration(duration) |
197 | | - runURL := runStat.url |
| 174 | + runURL := fmt.Sprintf("%s?run=%s", workflowURL, run.ID) |
198 | 175 | sb.WriteString(fmt.Sprintf("| %s | %d | %s | [View](%s) |\n", date, machines, durationStr, runURL)) |
199 | 176 | } |
200 | 177 | sb.WriteString("\n") |
201 | | - sb.WriteString("Use the `--machines` flag to set the number of machines to run the workflow on.\n\n") |
| 178 | + sb.WriteString("Use the `--machines` flag to set the number of machines (maximum parallelism) to run the workflow on.\n\n") |
202 | 179 | } |
203 | 180 |
|
204 | 181 | // Long description (README content) |
|
0 commit comments