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

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

Issue 2748073006: Milo Refactor: Remove theme support (Closed)
Patch Set: Fix builder.html pointer Created 3 years, 9 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 "errors"
8 "fmt" 9 "fmt"
9 "net/http"
10 "sort" 10 "sort"
11 "strings" 11 "strings"
12 "time" 12 "time"
13 13
14 » ds "github.com/luci/gae/service/datastore" 14 » "github.com/luci/gae/service/datastore"
15 15
16 "github.com/luci/luci-go/common/clock" 16 "github.com/luci/luci-go/common/clock"
17 "github.com/luci/luci-go/common/logging" 17 "github.com/luci/luci-go/common/logging"
18 "github.com/luci/luci-go/milo/api/resp" 18 "github.com/luci/luci-go/milo/api/resp"
19 "github.com/luci/luci-go/milo/common/miloerror"
20 "golang.org/x/net/context" 19 "golang.org/x/net/context"
21 ) 20 )
22 21
23 // builderRef is used for keying specific builds in a master json. 22 // builderRef is used for keying specific builds in a master json.
24 type builderRef struct { 23 type builderRef struct {
25 builder string 24 builder string
26 buildNum int 25 buildNum int
27 } 26 }
28 27
29 // buildMap contains all of the current build within a master json. We use this 28 // buildMap contains all of the current build within a master json. We use this
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 83 }
85 84
86 // getBuilds fetches all of the recent builds from the . Note that 85 // getBuilds fetches all of the recent builds from the . Note that
87 // getBuilds() does not perform ACL checks. 86 // getBuilds() does not perform ACL checks.
88 func getBuilds( 87 func getBuilds(
89 c context.Context, masterName, builderName string, finished bool, limit int) ( 88 c context.Context, masterName, builderName string, finished bool, limit int) (
90 []*resp.BuildSummary, error) { 89 []*resp.BuildSummary, error) {
91 90
92 // TODO(hinoka): Builder specific structs. 91 // TODO(hinoka): Builder specific structs.
93 result := []*resp.BuildSummary{} 92 result := []*resp.BuildSummary{}
94 » q := ds.NewQuery("buildbotBuild") 93 » q := datastore.NewQuery("buildbotBuild")
95 q = q.Eq("finished", finished) 94 q = q.Eq("finished", finished)
96 q = q.Eq("master", masterName) 95 q = q.Eq("master", masterName)
97 q = q.Eq("builder", builderName) 96 q = q.Eq("builder", builderName)
98 if limit != 0 { 97 if limit != 0 {
99 q = q.Limit(int32(limit)) 98 q = q.Limit(int32(limit))
100 } 99 }
101 q = q.Order("-number") 100 q = q.Order("-number")
102 buildbots := []*buildbotBuild{} 101 buildbots := []*buildbotBuild{}
103 err := getBuildQueryBatcher(c).GetAll(c, q, &buildbots) 102 err := getBuildQueryBatcher(c).GetAll(c, q, &buildbots)
104 if err != nil { 103 if err != nil {
105 return nil, err 104 return nil, err
106 } 105 }
107 for _, b := range buildbots { 106 for _, b := range buildbots {
108 result = append(result, getBuildSummary(b)) 107 result = append(result, getBuildSummary(b))
109 } 108 }
110 return result, nil 109 return result, nil
111 } 110 }
112 111
113 var errMasterNotFound = miloerror.Error{ 112 var errMasterNotFound = errors.New(
114 » Message: "Either the request resource was not found or you are not autho rized", 113 » "Either the request resource was not found or you have insufficient perm issions")
115 » Code: http.StatusNotFound, 114 var errNotAuth = errors.New("You are not authenticated, try logging in")
116 }
117
118 var errNotAuth = miloerror.Error{
119 » Message: "You are not authenticated, try logging in",
120 » Code: http.StatusUnauthorized,
121 }
122 115
123 // builderImpl is the implementation for getting a milo builder page from buildb ot. 116 // builderImpl is the implementation for getting a milo builder page from buildb ot.
124 // This gets: 117 // This gets:
125 // * Current Builds from querying the master json from the datastore. 118 // * Current Builds from querying the master json from the datastore.
126 // * Recent Builds from a cron job that backfills the recent builds. 119 // * Recent Builds from a cron job that backfills the recent builds.
127 func builderImpl(c context.Context, masterName, builderName string, limit int) ( *resp.Builder, error) { 120 func builderImpl(c context.Context, masterName, builderName string, limit int) ( *resp.Builder, error) {
128 result := &resp.Builder{ 121 result := &resp.Builder{
129 Name: builderName, 122 Name: builderName,
130 } 123 }
131 master, t, err := getMasterJSON(c, masterName) 124 master, t, err := getMasterJSON(c, masterName)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 181 }
189 result.CurrentBuilds = currentBuilds 182 result.CurrentBuilds = currentBuilds
190 183
191 for _, fb := range finishedBuilds { 184 for _, fb := range finishedBuilds {
192 if fb != nil { 185 if fb != nil {
193 result.FinishedBuilds = append(result.FinishedBuilds, fb ) 186 result.FinishedBuilds = append(result.FinishedBuilds, fb )
194 } 187 }
195 } 188 }
196 return result, nil 189 return result, nil
197 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698