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

Unified Diff: milo/appengine/buildbot/builder.go

Issue 2328733002: Milo: Add ?limit= support to builders (Closed)
Patch Set: Regenerate Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/api/proto/pb.discovery.go ('k') | milo/appengine/buildbot/html.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/buildbot/builder.go
diff --git a/milo/appengine/buildbot/builder.go b/milo/appengine/buildbot/builder.go
index 86195e4fc7ace8e5b38d1e77bc2a289c3b9464bc..767fa47c202123d79536bbf6caf38c2cb8afd91b 100644
--- a/milo/appengine/buildbot/builder.go
+++ b/milo/appengine/buildbot/builder.go
@@ -63,14 +63,17 @@ func getBuildSummary(b *buildbotBuild) *resp.BuildSummary {
// getBuilds fetches all of the recent builds from the . Note that
// getBuilds() does not perform ACL checks.
-func getBuilds(c context.Context, masterName, builderName string, finished bool) ([]*resp.BuildSummary, error) {
+func getBuilds(
+ c context.Context, masterName, builderName string, finished bool, limit int) (
+ []*resp.BuildSummary, error) {
+
// TODO(hinoka): Builder specific structs.
result := []*resp.BuildSummary{}
q := ds.NewQuery("buildbotBuild")
q = q.Eq("finished", finished)
q = q.Eq("master", masterName)
q = q.Eq("builder", builderName)
- q = q.Limit(25) // TODO(hinoka): This should be adjustable
+ q = q.Limit(int32(limit))
q = q.Order("-number")
buildbots := []*buildbotBuild{}
err := ds.GetAll(c, q, &buildbots)
@@ -113,7 +116,7 @@ func getCurrentBuilds(c context.Context, master *buildbotMaster, builderName str
// This gets:
// * Current Builds from querying the master json from the datastore.
// * Recent Builds from a cron job that backfills the recent builds.
-func builderImpl(c context.Context, masterName, builderName string) (*resp.Builder, error) {
+func builderImpl(c context.Context, masterName, builderName string, limit int) (*resp.Builder, error) {
result := &resp.Builder{
Name: builderName,
}
@@ -168,11 +171,11 @@ func builderImpl(c context.Context, masterName, builderName string) (*resp.Build
}
}
- recentBuilds, err := getBuilds(c, masterName, builderName, true)
+ recentBuilds, err := getBuilds(c, masterName, builderName, true, limit)
if err != nil {
return nil, err
}
- currentBuilds, err := getBuilds(c, masterName, builderName, false)
+ currentBuilds, err := getBuilds(c, masterName, builderName, false, 0)
if err != nil {
return nil, err
}
« no previous file with comments | « milo/api/proto/pb.discovery.go ('k') | milo/appengine/buildbot/html.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698