···33import (
44 "fmt"
55 "slices"
66+ "strings"
67 "time"
7889 "github.com/bluesky-social/indigo/atproto/syntax"
···5657 }
57585859 return 0
6060+}
6161+6262+// produces short summary of successes:
6363+// - "0/4" when zero successes of 4 workflows
6464+// - "4/4" when all successes of 4 workflows
6565+// - "0/0" when no workflows run in this pipeline
6666+func (p Pipeline) ShortStatusSummary() string {
6767+ counts := make(map[spindle.StatusKind]int)
6868+ for _, w := range p.Statuses {
6969+ counts[w.Latest().Status] += 1
7070+ }
7171+7272+ total := len(p.Statuses)
7373+ successes := counts[spindle.StatusKindSuccess]
7474+7575+ return fmt.Sprintf("%d/%d", successes, total)
7676+}
7777+7878+// produces a string of the form "3/4 success, 2/4 failed, 1/4 pending"
7979+func (p Pipeline) LongStatusSummary() string {
8080+ counts := make(map[spindle.StatusKind]int)
8181+ for _, w := range p.Statuses {
8282+ counts[w.Latest().Status] += 1
8383+ }
8484+8585+ total := len(p.Statuses)
8686+8787+ var result []string
8888+ // finish states first, followed by start states
8989+ states := append(spindle.FinishStates[:], spindle.StartStates[:]...)
9090+ for _, state := range states {
9191+ if count, ok := counts[state]; ok {
9292+ result = append(result, fmt.Sprintf("%d/%d %s", count, total, state.String()))
9393+ }
9494+ }
9595+9696+ return strings.Join(result, ", ")
5997}
60986199func (p Pipeline) Counts() map[string]int {