diff --git a/appview/models/pipeline.go b/appview/models/pipeline.go
index 6617786c..af843c4f 100644
--- a/appview/models/pipeline.go
+++ b/appview/models/pipeline.go
@@ -3,6 +3,7 @@ package models
import (
"fmt"
"slices"
+ "strings"
"time"
"github.com/bluesky-social/indigo/atproto/syntax"
@@ -58,6 +59,43 @@ func (w WorkflowStatus) TimeTaken() time.Duration {
return 0
}
+// produces short summary of successes:
+// - "0/4" when zero successes of 4 workflows
+// - "4/4" when all successes of 4 workflows
+// - "0/0" when no workflows run in this pipeline
+func (p Pipeline) ShortStatusSummary() string {
+ counts := make(map[spindle.StatusKind]int)
+ for _, w := range p.Statuses {
+ counts[w.Latest().Status] += 1
+ }
+
+ total := len(p.Statuses)
+ successes := counts[spindle.StatusKindSuccess]
+
+ return fmt.Sprintf("%d/%d", successes, total)
+}
+
+// produces a string of the form "3/4 success, 2/4 failed, 1/4 pending"
+func (p Pipeline) LongStatusSummary() string {
+ counts := make(map[spindle.StatusKind]int)
+ for _, w := range p.Statuses {
+ counts[w.Latest().Status] += 1
+ }
+
+ total := len(p.Statuses)
+
+ var result []string
+ // finish states first, followed by start states
+ states := append(spindle.FinishStates[:], spindle.StartStates[:]...)
+ for _, state := range states {
+ if count, ok := counts[state]; ok {
+ result = append(result, fmt.Sprintf("%d/%d %s", count, total, state.String()))
+ }
+ }
+
+ return strings.Join(result, ", ")
+}
+
func (p Pipeline) Counts() map[string]int {
m := make(map[string]int)
for _, w := range p.Statuses {
diff --git a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
index 6dea6bca..c655a2c9 100644
--- a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
+++ b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
@@ -1,74 +1,65 @@
{{ define "repo/pipelines/fragments/pipelineSymbol" }}
-
- {{ $c := .Counts }}
- {{ $statuses := .Statuses }}
- {{ $total := len $statuses }}
- {{ $success := index $c "success" }}
- {{ $fail := index $c "failed" }}
- {{ $timeout := index $c "timeout" }}
- {{ $empty := eq $total 0 }}
- {{ $allPass := eq $success $total }}
- {{ $allFail := eq $fail $total }}
- {{ $allTimeout := eq $timeout $total }}
-
- {{ if $empty }}
-
- {{ i "hourglass" "size-4 text-gray-600 dark:text-gray-400 " }}
- 0/{{ $total }}
-
- {{ else if $allPass }}
-
- {{ i "check" "size-4 text-green-600" }}
- {{ $total }}/{{ $total }}
-
- {{ else if $allFail }}
-
- {{ i "x" "size-4 text-red-500" }}
- 0/{{ $total }}
-
- {{ else if $allTimeout }}
-
- {{ i "clock-alert" "size-4 text-orange-500" }}
- 0/{{ $total }}
-
+
+ {{ template "symbol" .Pipeline }}
+ {{ if .ShortSummary }}
+ {{ .Pipeline.ShortStatusSummary }}
{{ else }}
- {{ $radius := f64 8 }}
- {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }}
- {{ $offset := 0.0 }}
-
-
- {{ $success }}/{{ $total }}
-
+ {{ .Pipeline.LongStatusSummary }}
{{ end }}
{{ end }}
+
+{{ define "symbol" }}
+ {{ $c := .Counts }}
+ {{ $statuses := .Statuses }}
+ {{ $total := len $statuses }}
+ {{ $success := index $c "success" }}
+ {{ $fail := index $c "failed" }}
+ {{ $timeout := index $c "timeout" }}
+ {{ $empty := eq $total 0 }}
+ {{ $allPass := eq $success $total }}
+ {{ $allFail := eq $fail $total }}
+ {{ $allTimeout := eq $timeout $total }}
+
+ {{ if $empty }}
+ {{ i "hourglass" "size-4 text-gray-600 dark:text-gray-400 " }}
+ {{ else if $allPass }}
+ {{ i "check" "size-4 text-green-600 dark:text-green-500" }}
+ {{ else if $allFail }}
+ {{ i "x" "size-4 text-red-600 dark:text-red-500" }}
+ {{ else if $allTimeout }}
+ {{ i "clock-alert" "size-4 text-orange-500" }}
+ {{ else }}
+ {{ $radius := f64 8 }}
+ {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }}
+ {{ $offset := 0.0 }}
+
+ {{ end }}
+{{ end }}
diff --git a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
index ce20e415..80b8bb86 100644
--- a/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
+++ b/appview/pages/templates/repo/pipelines/fragments/pipelineSymbolLong.html
@@ -4,7 +4,7 @@
- {{ template "repo/pipelines/fragments/pipelineSymbol" .Pipeline }}
+ {{ template "repo/pipelines/fragments/pipelineSymbol" (dict "Pipeline" $pipeline "ShortSummary" true) }}
{{ template "repo/pipelines/fragments/tooltip" $ }}