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

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

Issue 2328733002: Milo: Add ?limit= support to builders (Closed)
Patch Set: Rebase 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 | « no previous file | milo/appengine/buildbot/html.go » ('j') | milo/appengine/buildbucket/html.go » ('J')
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 c86758878ae316ee60a5863126257886f6d4452c..b345b9af39398e99e076d8bd0ed6e603ba43b6cc 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{}
master, t, err := getMasterJSON(c, masterName)
switch {
@@ -166,7 +169,7 @@ 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
}
« no previous file with comments | « no previous file | milo/appengine/buildbot/html.go » ('j') | milo/appengine/buildbucket/html.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698