{{ 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 }}
{{ else }} {{ $radius := f64 8 }} {{ $circumference := mulf64 2.0 (mulf64 3.1416 $radius) }} {{ $offset := 0.0 }}
{{ range $kind, $count := $c }} {{ $color := "" }} {{ if or (eq $kind "pending") (eq $kind "running") }} {{ $color = "#eab308" }} {{/* amber-500 */}} {{ else if eq $kind "success" }} {{ $color = "#10b981" }} {{/* green-500 */}} {{ else if eq $kind "cancelled" }} {{ $color = "#6b7280" }} {{/* gray-500 */}} {{ else if eq $kind "timeout" }} {{ $color = "#fb923c" }} {{/* orange-400 */}} {{ else }} {{ $color = "#ef4444" }} {{/* red-500 for failed or unknown */}} {{ end }} {{ $percent := divf64 (f64 $count) (f64 $total) }} {{ $length := mulf64 $percent $circumference }} {{ $offset = addf64 $offset $length }} {{ end }} {{ $success }}/{{ $total }}
{{ end }}
{{ end }}