|
9 | 9 | "strconv" |
10 | 10 | "strings" |
11 | 11 |
|
| 12 | + "github.com/github/gh-aw/pkg/console" |
12 | 13 | "github.com/github/gh-aw/pkg/constants" |
13 | 14 | ghmapping "github.com/github/gh-aw/pkg/github" |
14 | 15 | "github.com/github/gh-aw/pkg/workflow" |
@@ -162,7 +163,7 @@ func RunOutcomesHistory(config OutcomesHistoryConfig) error { |
162 | 163 | return nil |
163 | 164 | } |
164 | 165 |
|
165 | | - fmt.Fprintf(os.Stderr, "Objective history for %s (limit %d)\n", repo, config.Limit) |
| 166 | + fmt.Fprintln(os.Stderr, console.FormatSectionHeader(fmt.Sprintf("Objective history for %s (limit %d)", repo, config.Limit))) |
166 | 167 | if data.Issues != nil { |
167 | 168 | renderHistoricalObjectiveReport(*data.Issues) |
168 | 169 | } |
@@ -295,22 +296,41 @@ func buildHistoricalObjectiveReport(source string, items []historicalGitHubItem, |
295 | 296 | } |
296 | 297 |
|
297 | 298 | func renderHistoricalObjectiveReport(report historicalObjectiveReport) { |
298 | | - fmt.Fprintf(os.Stderr, "\n%s\n", strings.ToUpper(report.Source)) |
299 | | - fmt.Fprintf(os.Stderr, " Sample size: %d\n", report.SampleSize) |
300 | | - fmt.Fprintf(os.Stderr, " Scored items: %d\n", report.ScoredItems) |
301 | | - fmt.Fprintf(os.Stderr, " Total objective value: %d\n", report.TotalObjectiveValue) |
| 299 | + fmt.Fprintf(os.Stderr, "\n%s\n", console.FormatSectionHeader(strings.ToUpper(report.Source))) |
| 300 | + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Sample size: %d", report.SampleSize))) |
| 301 | + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Scored items: %d", report.ScoredItems))) |
| 302 | + fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Total objective value: %d", report.TotalObjectiveValue))) |
302 | 303 |
|
303 | 304 | if len(report.ObjectiveBuckets) > 0 { |
304 | | - fmt.Fprintln(os.Stderr, " Top objective buckets:") |
| 305 | + bucketRows := make([][]string, 0, min(len(report.ObjectiveBuckets), 8)) |
305 | 306 | for _, bucket := range report.ObjectiveBuckets[:min(len(report.ObjectiveBuckets), 8)] { |
306 | | - fmt.Fprintf(os.Stderr, " %-22s %3d x %3d = %4d\n", bucket.Label, bucket.Count, bucket.MappedValue, bucket.ContributedValue) |
| 307 | + bucketRows = append(bucketRows, []string{ |
| 308 | + bucket.Label, |
| 309 | + strconv.Itoa(bucket.Count), |
| 310 | + strconv.Itoa(bucket.MappedValue), |
| 311 | + strconv.Itoa(bucket.ContributedValue), |
| 312 | + }) |
307 | 313 | } |
| 314 | + fmt.Fprint(os.Stderr, console.RenderTable(console.TableConfig{ |
| 315 | + Title: "Top objective buckets", |
| 316 | + Headers: []string{"Bucket", "Count", "Mapped Value", "Contributed Value"}, |
| 317 | + Rows: bucketRows, |
| 318 | + })) |
308 | 319 | } |
309 | 320 |
|
310 | 321 | if len(report.RepresentativeItems) > 0 { |
311 | | - fmt.Fprintln(os.Stderr, " Representative items:") |
| 322 | + itemRows := make([][]string, 0, min(len(report.RepresentativeItems), 5)) |
312 | 323 | for _, item := range report.RepresentativeItems[:min(len(report.RepresentativeItems), 5)] { |
313 | | - fmt.Fprintf(os.Stderr, " #%d %-3d %s\n", item.Number, item.ObjectiveValue, item.Title) |
| 324 | + itemRows = append(itemRows, []string{ |
| 325 | + fmt.Sprintf("#%d", item.Number), |
| 326 | + strconv.Itoa(item.ObjectiveValue), |
| 327 | + item.Title, |
| 328 | + }) |
314 | 329 | } |
| 330 | + fmt.Fprint(os.Stderr, console.RenderTable(console.TableConfig{ |
| 331 | + Title: "Representative items", |
| 332 | + Headers: []string{"Number", "Value", "Title"}, |
| 333 | + Rows: itemRows, |
| 334 | + })) |
315 | 335 | } |
316 | 336 | } |
0 commit comments