| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| 11 ds "github.com/luci/gae/service/datastore" | 11 ds "github.com/luci/gae/service/datastore" |
| 12 "github.com/luci/luci-go/common/clock" | 12 "github.com/luci/luci-go/common/clock" |
| 13 log "github.com/luci/luci-go/common/logging" | 13 log "github.com/luci/luci-go/common/logging" |
| 14 "github.com/luci/luci-go/common/sync/parallel" | 14 "github.com/luci/luci-go/common/sync/parallel" |
| 15 "github.com/luci/luci-go/milo/api/resp" | 15 "github.com/luci/luci-go/milo/api/resp" |
| 16 "github.com/luci/luci-go/milo/appengine/common/model" |
| 16 | 17 |
| 17 "golang.org/x/net/context" | 18 "golang.org/x/net/context" |
| 18 ) | 19 ) |
| 19 | 20 |
| 20 // getFullBuilds fetches all of the recent builds from the datastore. | 21 // getFullBuilds fetches all of the recent builds from the datastore. |
| 21 func getFullBuilds(c context.Context, masterName, builderName string, finished b
ool) ([]*buildbotBuild, error) { | 22 func getFullBuilds(c context.Context, masterName, builderName string, finished b
ool) ([]*buildbotBuild, error) { |
| 22 // TODO(hinoka): Builder specific structs. | 23 // TODO(hinoka): Builder specific structs. |
| 23 q := ds.NewQuery("buildbotBuild") | 24 q := ds.NewQuery("buildbotBuild") |
| 24 q = q.Eq("finished", finished) | 25 q = q.Eq("finished", finished) |
| 25 q = q.Eq("master", masterName) | 26 q = q.Eq("master", masterName) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 60 } |
| 60 master := builderComponents[0] | 61 master := builderComponents[0] |
| 61 builderName := builderComponents[1] | 62 builderName := builderComponents[1] |
| 62 taskC <- func() error { | 63 taskC <- func() error { |
| 63 t1 := clock.Now(c) | 64 t1 := clock.Now(c) |
| 64 builds, err := getFullBuilds(c, master, builderN
ame, true) | 65 builds, err := getFullBuilds(c, master, builderN
ame, true) |
| 65 if err != nil { | 66 if err != nil { |
| 66 return err | 67 return err |
| 67 } | 68 } |
| 68 t2 := clock.Now(c) | 69 t2 := clock.Now(c) |
| 69 » » » » var currentStatus *resp.Status | 70 » » » » var currentStatus *model.Status |
| 70 for j, commit := range commits { | 71 for j, commit := range commits { |
| 71 for _, build := range builds { | 72 for _, build := range builds { |
| 72 if build.Sourcestamp.Revision ==
commit { | 73 if build.Sourcestamp.Revision ==
commit { |
| 73 results[j][i] = &resp.Co
nsoleBuild{ | 74 results[j][i] = &resp.Co
nsoleBuild{ |
| 74 » » » » » » » » Link: &resp.Link
{ | 75 » » » » » » » » Link: resp.NewLi
nk( |
| 75 » » » » » » » » » Label: s
trings.Join(build.Text, " "), | 76 » » » » » » » » » strings.
Join(build.Text, " "), |
| 76 » » » » » » » » » URL: fmt
.Sprintf( | 77 » » » » » » » » » fmt.Spri
ntf("/buildbot/%s/%s/%d", master, builderName, build.Number), |
| 77 » » » » » » » » » »
"/buildbot/%s/%s/%d", master, builderName, build.Number), | 78 » » » » » » » » ), |
| 78 » » » » » » » » }, | |
| 79 Status: build.to
Status(), | 79 Status: build.to
Status(), |
| 80 } | 80 } |
| 81 currentStatus = &results
[j][i].Status | 81 currentStatus = &results
[j][i].Status |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 if currentStatus != nil && results[j][i]
== nil { | 84 if currentStatus != nil && results[j][i]
== nil { |
| 85 results[j][i] = &resp.ConsoleBui
ld{Status: *currentStatus} | 85 results[j][i] = &resp.ConsoleBui
ld{Status: *currentStatus} |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 log.Debugf(c, | 88 log.Debugf(c, |
| 89 "Builder %s took %s to query, %s to comp
ute.", builderName, | 89 "Builder %s took %s to query, %s to comp
ute.", builderName, |
| 90 t2.Sub(t1), clock.Since(c, t2)) | 90 t2.Sub(t1), clock.Since(c, t2)) |
| 91 return nil | 91 return nil |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 }) | 94 }) |
| 95 return results, err | 95 return results, err |
| 96 } | 96 } |
| OLD | NEW |