-
Notifications
You must be signed in to change notification settings - Fork 237
/
jobs.go
63 lines (53 loc) · 1.24 KB
/
jobs.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
58
59
60
61
62
63
package schemas
import (
"strings"
goGitlab "github.com/xanzy/go-gitlab"
)
// Job ..
type Job struct {
ID int
Name string
Stage string
Timestamp float64
DurationSeconds float64
QueuedDurationSeconds float64
Status string
TagList string
ArtifactSize float64
FailureReason string
Runner Runner
}
// Runner ..
type Runner struct {
Description string
}
// Jobs ..
type Jobs map[string]Job
// NewJob ..
func NewJob(gj goGitlab.Job) Job {
var (
artifactSize float64
timestamp float64
)
for _, artifact := range gj.Artifacts {
artifactSize += float64(artifact.Size)
}
if gj.CreatedAt != nil {
timestamp = float64(gj.CreatedAt.Unix())
}
return Job{
ID: gj.ID,
Name: gj.Name,
Stage: gj.Stage,
Timestamp: timestamp,
DurationSeconds: gj.Duration,
QueuedDurationSeconds: gj.QueuedDuration,
Status: gj.Status,
TagList: strings.Join(gj.TagList, ","),
ArtifactSize: artifactSize,
FailureReason: gj.FailureReason,
Runner: Runner{
Description: gj.Runner.Description,
},
}
}