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

Side by Side Diff: milo/appengine/buildbucket/html.go

Issue 2328733002: Milo: Add ?limit= support to builders (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 buildbucket 5 package buildbucket
6 6
7 import ( 7 import (
8 "fmt"
9 "net/http" 8 "net/http"
10 "strconv"
11 9
12 "github.com/julienschmidt/httprouter" 10 "github.com/julienschmidt/httprouter"
13 "golang.org/x/net/context" 11 "golang.org/x/net/context"
14 12
15 "github.com/luci/luci-go/milo/appengine/settings" 13 "github.com/luci/luci-go/milo/appengine/settings"
16 "github.com/luci/luci-go/milo/common/miloerror" 14 "github.com/luci/luci-go/milo/common/miloerror"
17 "github.com/luci/luci-go/server/templates" 15 "github.com/luci/luci-go/server/templates"
18 ) 16 )
19 17
20 // TODO(nodir): move this value to luci-config. 18 // TODO(nodir): move this value to luci-config.
(...skipping 24 matching lines...) Expand all
45 } 43 }
46 44
47 builder := p.ByName("builder") 45 builder := p.ByName("builder")
48 if builder == "" { 46 if builder == "" {
49 return nil, &miloerror.Error{ 47 return nil, &miloerror.Error{
50 Message: "No builder", 48 Message: "No builder",
51 Code: http.StatusBadRequest, 49 Code: http.StatusBadRequest,
52 } 50 }
53 } 51 }
54 52
55 » // numbuilds is a name of buildbot's query string parameter for specifyi ng 53 » // limit is a name of the query string parameter for specifying
nodir 2016/10/28 07:17:54 this function does not know the name of the query
hinoka 2016/10/28 19:47:30 Removed...
56 // maximum number of builds to show. 54 // maximum number of builds to show.
57 » // We are retaining the parameter name for user convenience. 55 » limit, err := settings.GetLimit(r)
58 » numBuildsStr := r.FormValue("numbuilds")
59 » numBuilds := -1
60 » if numBuildsStr != "" {
61 » » var err error
62 » » numBuilds, err = strconv.Atoi(numBuildsStr)
63 » » if err != nil {
64 » » » return nil, &miloerror.Error{
65 » » » » Message: fmt.Sprintf("numbuilds parameter value %q is not a number: %s", numBuildsStr, err),
66 » » » » Code: http.StatusBadRequest,
67 » » » }
68 » » }
69 » }
70
71 » result, err := builderImpl(c, server, bucket, builder, numBuilds)
72 if err != nil { 56 if err != nil {
73 return nil, err 57 return nil, err
74 } 58 }
59
60 result, err := builderImpl(c, server, bucket, builder, limit)
61 if err != nil {
62 return nil, err
63 }
75 64
76 // Render into the template 65 // Render into the template
77 args := &templates.Args{ 66 args := &templates.Args{
78 "Builder": result, 67 "Builder": result,
79 } 68 }
80 return args, nil 69 return args, nil
81 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698