Skip to content

Commit 6e4b603

Browse files
committed
Add Duration col
1 parent 4fedda8 commit 6e4b603

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

commands/Jobs.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
dmConfig "github.com/DataManager-Go/libdatamanager/config"
1313
librb "github.com/JojiiOfficial/LibRemotebuild"
1414
"github.com/fatih/color"
15-
humanTime "github.com/sbani/go-humanizer/time"
1615
clitable "gopkg.in/benweidig/cli-table.v2"
1716
)
1817

@@ -42,7 +41,7 @@ func (cData *CommandData) ListJobs(limit int) {
4241
header = append(header, headingColor.Sprint("Pos"))
4342
jobWithPos = true
4443
}
45-
header = append(header, []interface{}{headingColor.Sprint("Job Type"), headingColor.Sprint("Upload Type"), headingColor.Sprint("Status")}...)
44+
header = append(header, []interface{}{headingColor.Sprint("Job Type"), headingColor.Sprint("Upload Type"), headingColor.Sprint("Status"), headingColor.Sprint("Duration")}...)
4645

4746
table.AddRow(header...)
4847

@@ -54,7 +53,11 @@ func (cData *CommandData) ListJobs(limit int) {
5453
}
5554

5655
if jobWithPos {
57-
rowitems = append(rowitems, job.Position)
56+
if job.Position > 0 {
57+
rowitems = append(rowitems, job.Position)
58+
} else {
59+
rowitems = append(rowitems, "-")
60+
}
5861
}
5962

6063
rowitems = append(rowitems, []interface{}{
@@ -63,9 +66,15 @@ func (cData *CommandData) ListJobs(limit int) {
6366
}...)
6467

6568
if job.Status == librb.JobRunning {
66-
rowitems = append(rowitems, "Started "+humanTime.Difference(time.Now(), job.RunningSince))
69+
rowitems = append(rowitems, "Running")
70+
rowitems = append(rowitems, time.Since(job.RunningSince))
6771
} else {
6872
rowitems = append(rowitems, job.Status)
73+
if job.Duration.Seconds() > 0 {
74+
rowitems = append(rowitems, job.Duration.String())
75+
} else {
76+
rowitems = append(rowitems, "-")
77+
}
6978
}
7079

7180
table.AddRow(rowitems...)

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.14
55
require (
66
github.com/DataManager-Go/libdatamanager v1.3.8 // indirect
77
github.com/DataManager-Go/libdatamanager/config v0.0.0-20200717181208-26ce39a85e00
8-
github.com/JojiiOfficial/LibRemotebuild v0.1.7
9-
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719190817-656fb15fe37d
8+
github.com/JojiiOfficial/LibRemotebuild v0.1.8
9+
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719194342-a1415068815f
1010
github.com/JojiiOfficial/configService v0.0.0-20200219132202-6e71512e2e28
1111
github.com/JojiiOfficial/gaw v1.2.8
1212
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
@@ -16,7 +16,6 @@ require (
1616
github.com/jinzhu/gorm v1.9.15 // indirect
1717
github.com/mattn/go-runewidth v0.0.9 // indirect
1818
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
19-
github.com/sbani/go-humanizer v0.3.1
2019
github.com/zalando/go-keyring v0.1.0
2120
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
2221
gopkg.in/alecthomas/kingpin.v2 v2.2.6

go.sum

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ github.com/DataManager-Go/libdatamanager/config v0.0.0-20200717181208-26ce39a85e
77
github.com/DataManager-Go/libdatamanager/config v0.0.0-20200717181208-26ce39a85e00/go.mod h1:YHPA+ryhCc4xY130Az+ScF9zkRNGdHuz09eZXiULhrw=
88
github.com/JojiiOfficial/LibRemotebuild v0.0.3 h1:MdXvqIlVcdXCcBf/XDbPxvhCF+Wwurijr4J7kNeNjI0=
99
github.com/JojiiOfficial/LibRemotebuild v0.0.3/go.mod h1:NS5D8NlALafEHK8LmRctE22sM4JjOlZyCwoXA//P2nU=
10-
github.com/JojiiOfficial/LibRemotebuild v0.1.6 h1:r3t6W/r7/OIbKHH79rzbdwEbneL+5a2C20LKrw61es4=
11-
github.com/JojiiOfficial/LibRemotebuild v0.1.6/go.mod h1:NS5D8NlALafEHK8LmRctE22sM4JjOlZyCwoXA//P2nU=
12-
github.com/JojiiOfficial/LibRemotebuild v0.1.7 h1:T7feY82UZsbxm1/ZYbfVMg9sTptjyd/NqZTPIh+5BNY=
13-
github.com/JojiiOfficial/LibRemotebuild v0.1.7/go.mod h1:NS5D8NlALafEHK8LmRctE22sM4JjOlZyCwoXA//P2nU=
14-
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719190817-656fb15fe37d h1:u+9737TTrBGgRSJFS+yMym1+LdVt+eWK7kLH3kzXCuU=
15-
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719190817-656fb15fe37d/go.mod h1:lxGR/6KclpgZK45zYp8Fez3LbhrWIOI3ZYM0jFAkYFo=
10+
github.com/JojiiOfficial/LibRemotebuild v0.1.8 h1:jeZkbsnlje+8AWw6U/zjJsjkDkYM17rvcKrDaW2lRPY=
11+
github.com/JojiiOfficial/LibRemotebuild v0.1.8/go.mod h1:NS5D8NlALafEHK8LmRctE22sM4JjOlZyCwoXA//P2nU=
12+
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719194342-a1415068815f h1:porS9UqS7J/yYqyq3qRvHNJ4AALQa/LiP3kL0u7Dg/U=
13+
github.com/JojiiOfficial/LibRemotebuild/config v0.0.0-20200719194342-a1415068815f/go.mod h1:lxGR/6KclpgZK45zYp8Fez3LbhrWIOI3ZYM0jFAkYFo=
1614
github.com/JojiiOfficial/configService v0.0.0-20200219132202-6e71512e2e28 h1:nYoIExG+Z/gSLS9Jbpu6lnrh+m6e9gTxQfGhanTsExE=
1715
github.com/JojiiOfficial/configService v0.0.0-20200219132202-6e71512e2e28/go.mod h1:j1kHFoYWAbLRPE5nyAAtODwUc0xwd2+ifPZ3uCAgv/g=
1816
github.com/JojiiOfficial/gaw v1.2.1 h1:zwVLf5TQrXQF+pwI+/sVsfxTxmAZbZ5BjVT/nKxb2Ck=
@@ -77,8 +75,6 @@ github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJK
7775
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
7876
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7977
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
80-
github.com/sbani/go-humanizer v0.3.1 h1:tknML0P8VM52Ve22s7yDmwR5+O/iYlcsB4LH+1wbbqo=
81-
github.com/sbani/go-humanizer v0.3.1/go.mod h1:e9VBnVLK9RD0xgcSvZDuL9gX9mSaCTr4xE+VSBuG2KM=
8278
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
8379
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8480
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=

0 commit comments

Comments
 (0)