forked from rjonczy/succint_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessor.go
57 lines (48 loc) · 1.08 KB
/
processor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"time"
)
func countFailedProofs(proofs []SuccintProof) int {
count := 0
for _, proof := range proofs {
if proof.Status == "failure" {
count++
}
}
return count
}
func countRunningProofs(proofs []SuccintProof) int {
count := 0
for _, proof := range proofs {
if proof.Status == "running" {
count++
}
}
return count
}
func getLatestSuccessTimestamp(proofs []SuccintProof) time.Time {
var latestSuccessTime time.Time
for _, proof := range proofs {
parsedTime, err := time.Parse(time.RFC3339, proof.CreatedAt)
if err != nil {
continue
}
if proof.Status == "success" && parsedTime.After(latestSuccessTime) {
latestSuccessTime = parsedTime
}
}
return latestSuccessTime
}
func getLatestFailureTimestamp(proofs []SuccintProof) time.Time {
var latestFailureTime time.Time
for _, proof := range proofs {
parsedTime, err := time.Parse(time.RFC3339, proof.CreatedAt)
if err != nil {
continue
}
if proof.Status == "failure" && parsedTime.After(latestFailureTime) {
latestFailureTime = parsedTime
}
}
return latestFailureTime
}