Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: appengine/cmd/milo/buildbot/builder.go

Issue 2196453002: Milo: Console view prototype (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Reviews Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/cmd/milo/Makefile ('k') | appengine/cmd/milo/buildbot/console.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "encoding/json" 8 "encoding/json"
9 "fmt" 9 "fmt"
10 "os" 10 "os"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Finished: finished, 56 Finished: finished,
57 Duration: duration, 57 Duration: duration,
58 }, 58 },
59 Text: b.Text, 59 Text: b.Text,
60 Blame: blame(b), 60 Blame: blame(b),
61 Revision: b.Sourcestamp.Revision, 61 Revision: b.Sourcestamp.Revision,
62 } 62 }
63 } 63 }
64 64
65 // getBuilds fetches all of the recent builds from the datastore. 65 // getBuilds fetches all of the recent builds from the datastore.
66 func getBuilds(c context.Context, masterName, builderName string) ([]*resp.Build Summary, error) { 66 func getBuilds(c context.Context, masterName, builderName string, finished bool) ([]*resp.BuildSummary, error) {
67 // TODO(hinoka): Builder specific structs. 67 // TODO(hinoka): Builder specific structs.
68 result := []*resp.BuildSummary{} 68 result := []*resp.BuildSummary{}
69 ds := datastore.Get(c) 69 ds := datastore.Get(c)
70 q := datastore.NewQuery("buildbotBuild") 70 q := datastore.NewQuery("buildbotBuild")
71 » q = q.Eq("finished", true) 71 » q = q.Eq("finished", finished)
72 q = q.Eq("master", masterName) 72 q = q.Eq("master", masterName)
73 q = q.Eq("builder", builderName) 73 q = q.Eq("builder", builderName)
74 q = q.Limit(25) // TODO(hinoka): This should be adjustable 74 q = q.Limit(25) // TODO(hinoka): This should be adjustable
75 q = q.Order("-number") 75 q = q.Order("-number")
76 buildbots := []*buildbotBuild{} 76 buildbots := []*buildbotBuild{}
77 err := ds.GetAll(q, &buildbots) 77 err := ds.GetAll(q, &buildbots)
78 if err != nil { 78 if err != nil {
79 return nil, err 79 return nil, err
80 } 80 }
81 for _, b := range buildbots { 81 for _, b := range buildbots {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 for k := range master.Builders { 142 for k := range master.Builders {
143 keys = append(keys, k) 143 keys = append(keys, k)
144 } 144 }
145 sort.Strings(keys) 145 sort.Strings(keys)
146 avail := strings.Join(keys, "\n") 146 avail := strings.Join(keys, "\n")
147 return nil, fmt.Errorf( 147 return nil, fmt.Errorf(
148 "Cannot find builder %s in master %s.\nAvailable builder s: \n%s", 148 "Cannot find builder %s in master %s.\nAvailable builder s: \n%s",
149 builderName, masterName, avail) 149 builderName, masterName, avail)
150 } 150 }
151 151
152 » recentBuilds, err := getBuilds(c, masterName, builderName) 152 » recentBuilds, err := getBuilds(c, masterName, builderName, true)
153 if err != nil { 153 if err != nil {
154 return nil, err // Or maybe not? 154 return nil, err // Or maybe not?
155 } 155 }
156 currentBuilds := getCurrentBuilds(c, master, builderName) 156 currentBuilds := getCurrentBuilds(c, master, builderName)
157 fmt.Fprintf(os.Stderr, "Number of current builds: %d\n", len(currentBuil ds)) 157 fmt.Fprintf(os.Stderr, "Number of current builds: %d\n", len(currentBuil ds))
158 result.CurrentBuilds = currentBuilds 158 result.CurrentBuilds = currentBuilds
159 for _, fb := range recentBuilds { 159 for _, fb := range recentBuilds {
160 // Yes recent builds is synonymous with finished builds. 160 // Yes recent builds is synonymous with finished builds.
161 // TODO(hinoka): Implement limits. 161 // TODO(hinoka): Implement limits.
162 if fb != nil { 162 if fb != nil {
163 result.FinishedBuilds = append(result.FinishedBuilds, fb ) 163 result.FinishedBuilds = append(result.FinishedBuilds, fb )
164 } 164 }
165 } 165 }
166 return result, nil 166 return result, nil
167 } 167 }
OLDNEW
« no previous file with comments | « appengine/cmd/milo/Makefile ('k') | appengine/cmd/milo/buildbot/console.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698