Chromium Code Reviews| Index: appengine/cmd/milo/logdog/logDogBuild.go |
| diff --git a/appengine/cmd/milo/logdog/logDogBuild.go b/appengine/cmd/milo/logdog/logDogBuild.go |
| index 9302f72bbb1dc8c4d6fae93eaa2e17d2551376c7..8d8f3c3d078be1fd51758c5f2941670a76a9a18a 100644 |
| --- a/appengine/cmd/milo/logdog/logDogBuild.go |
| +++ b/appengine/cmd/milo/logdog/logDogBuild.go |
| @@ -10,6 +10,7 @@ import ( |
| "time" |
| "github.com/luci/luci-go/appengine/cmd/milo/resp" |
| + "github.com/luci/luci-go/common/clock" |
| "github.com/luci/luci-go/common/logdog/types" |
| "github.com/luci/luci-go/common/logging" |
| miloProto "github.com/luci/luci-go/common/proto/milo" |
| @@ -17,11 +18,9 @@ import ( |
| ) |
| // Given a logdog/milo step, translate it to a BuildComponent struct. |
| -func miloBuildStep( |
| - c context.Context, url string, anno *miloProto.Step, name string) *resp.BuildComponent { |
| - comp := &resp.BuildComponent{} |
| +func miloBuildStep(c context.Context, url string, anno *miloProto.Step, name string) *resp.BuildComponent { |
| asc := anno.GetStepComponent() |
| - comp.Label = asc.Name |
| + comp := &resp.BuildComponent{Label: asc.Name} |
| switch asc.Status { |
| case miloProto.Status_RUNNING: |
| comp.Status = resp.Running |
| @@ -85,7 +84,17 @@ func miloBuildStep( |
| comp.LevelsDeep = 0 |
| // Timestamps |
| - comp.Started = asc.Started.Time().Format(time.RFC3339) |
| + started := asc.Started.Time() |
| + ended := asc.Ended.Time() |
| + comp.Started = started.Format(time.RFC3339) |
| + comp.Finished = ended.Format(time.RFC3339) |
|
estaab
2016/06/16 00:48:53
if you add
if asc.Status == miloProto.Status_RUNN
nodir
2016/06/16 17:14:55
Done.
|
| + if !started.IsZero() && (!ended.IsZero() || asc.Status == miloProto.Status_RUNNING) { |
| + till := ended |
| + if till.IsZero() { |
| + till = clock.Now(c) |
| + } |
| + comp.Duration = uint64((till.Sub(started)) / time.Second) |
| + } |
| // This should be the exact same thing. |
| comp.Text = asc.Text |
| @@ -94,11 +103,9 @@ func miloBuildStep( |
| } |
| // AddLogDogToBuild takes a set of logdog streams and populate a milo build. |
| -func AddLogDogToBuild( |
| - c context.Context, url string, s *Streams, |
| - build *resp.MiloBuild) { |
| +func AddLogDogToBuild(c context.Context, url string, s *Streams, build *resp.MiloBuild) { |
| if s.MainStream == nil { |
| - panic("Missing main stream") |
| + panic("missing main stream") |
| } |
| // Now Fetch the main annotation of the build. |
| mainAnno := s.MainStream.Data |