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

Side by Side Diff: milo/appengine/buildbot/console.go

Issue 2668763002: Use a datastore batcher for build queries. (Closed)
Patch Set: Created 3 years, 10 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
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 "fmt" 8 "fmt"
9 "strings" 9 "strings"
10 10
(...skipping 10 matching lines...) Expand all
21 func getFullBuilds(c context.Context, masterName, builderName string, finished b ool) ([]*buildbotBuild, error) { 21 func getFullBuilds(c context.Context, masterName, builderName string, finished b ool) ([]*buildbotBuild, error) {
22 // TODO(hinoka): Builder specific structs. 22 // TODO(hinoka): Builder specific structs.
23 q := ds.NewQuery("buildbotBuild") 23 q := ds.NewQuery("buildbotBuild")
24 q = q.Eq("finished", finished) 24 q = q.Eq("finished", finished)
25 q = q.Eq("master", masterName) 25 q = q.Eq("master", masterName)
26 q = q.Eq("builder", builderName) 26 q = q.Eq("builder", builderName)
27 q = q.Limit(25) // TODO(hinoka): This should be adjustable 27 q = q.Limit(25) // TODO(hinoka): This should be adjustable
28 q = q.Order("-number") 28 q = q.Order("-number")
29 q.Finalize() 29 q.Finalize()
30 buildbots := make([]*buildbotBuild, 0, 25) 30 buildbots := make([]*buildbotBuild, 0, 25)
31 » err := ds.GetAll(c, q, &buildbots) 31 » err := getBuildQueryBatcher(c).GetAll(c, q, &buildbots)
32 return buildbots, err 32 return buildbots, err
33 } 33 }
34 34
35 // GetConsoleBuilds takes commits and builders and returns a matrix of 35 // GetConsoleBuilds takes commits and builders and returns a matrix of
36 // resp.ConsoleBuild objects. The expected format of the result 36 // resp.ConsoleBuild objects. The expected format of the result
37 // is [len(commits)][len(builders)]*resp.ConsoleBuild. The first level matches 37 // is [len(commits)][len(builders)]*resp.ConsoleBuild. The first level matches
38 // 1:1 to a commit, and the second level matches 1:1 to a builder. 38 // 1:1 to a commit, and the second level matches 1:1 to a builder.
39 func GetConsoleBuilds( 39 func GetConsoleBuilds(
40 c context.Context, builders []resp.BuilderRef, commits []string) ( 40 c context.Context, builders []resp.BuilderRef, commits []string) (
41 [][]*resp.ConsoleBuild, error) { 41 [][]*resp.ConsoleBuild, error) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 log.Debugf(c, 89 log.Debugf(c,
90 "Builder %s took %s to query, %s to comp ute.", builderName, 90 "Builder %s took %s to query, %s to comp ute.", builderName,
91 t2.Sub(t1), clock.Since(c, t2)) 91 t2.Sub(t1), clock.Since(c, t2))
92 return nil 92 return nil
93 } 93 }
94 } 94 }
95 }) 95 })
96 return results, err 96 return results, err
97 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698