Chromium Code Reviews| Index: milo/appengine/buildbot/grpc.go |
| diff --git a/milo/appengine/buildbot/grpc.go b/milo/appengine/buildbot/grpc.go |
| index 5b696b864baeb60e4275093c7e4ac005cfef550a..36c9eaaa292e9b70735d8861d7986937cd938554 100644 |
| --- a/milo/appengine/buildbot/grpc.go |
| +++ b/milo/appengine/buildbot/grpc.go |
| @@ -53,6 +53,58 @@ func (s *Service) GetBuildbotBuildJSON( |
| return &milo.BuildbotBuildJSON{Data: bs}, nil |
| } |
| +func (s *Service) GetBuildbotBuildsJSON( |
|
martiniss
2016/10/06 21:18:56
Can you add a basic smoke test or two for this?
hinoka
2016/10/07 01:44:54
Done.
|
| + c context.Context, req *milo.BuildbotBuildsRequest) ( |
| + *milo.BuildbotBuildsJSON, error) { |
| + |
| + if req.Master == "" { |
| + return nil, grpc.Errorf(codes.InvalidArgument, "No master specified") |
| + } |
| + if req.Builder == "" { |
| + return nil, grpc.Errorf(codes.InvalidArgument, "No builder specified") |
| + } |
| + |
| + // Perform an ACL check by fetching the master. |
| + _, err := getMasterEntry(c, req.Master) |
| + switch { |
| + case err == errMasterNotFound: |
| + return nil, grpc.Errorf(codes.NotFound, "Master not found") |
| + case err != nil: |
| + return nil, err |
| + } |
| + |
| + limit := req.Limit |
| + if limit == 0 { |
| + limit = 50 |
|
martiniss
2016/10/06 21:18:56
buildbot default limit is 20, why not replicate th
hinoka
2016/10/07 01:44:54
test-results used 50 i think. Both are equally ar
|
| + } |
| + |
| + q := ds.NewQuery("buildbotBuild") |
| + q = q.Eq("master", req.Master). |
| + Eq("builder", req.Builder). |
| + Eq("finished", true). |
|
martiniss
2016/10/06 21:18:56
Do we want to always require finished? Can we make
hinoka
2016/10/07 01:44:54
Done.
|
| + Limit(limit). |
| + Order("-number") |
| + builds := []*buildbotBuild{} |
| + err = ds.GetAll(c, q, &builds) |
| + if err != nil { |
| + return nil, err |
| + } |
| + |
| + results := make([]*milo.BuildbotBuildJSON, len(builds)) |
| + for i, b := range builds { |
| + // In theory we could do this in parallel, but it doesn't actually go faster |
| + // since AppEngine is single-cored. |
| + bs, err := json.Marshal(b) |
| + if err != nil { |
| + return nil, err |
| + } |
| + results[i] = &milo.BuildbotBuildJSON{Data: bs} |
| + } |
| + return &milo.BuildbotBuildsJSON{ |
| + Builds: results, |
|
martiniss
2016/10/06 21:18:56
Is this going to run into app engine response size
hinoka
2016/10/07 01:44:54
Unlikely I think. The main issue we run into usua
|
| + }, nil |
| +} |
| + |
| // GetCompressedMasterJSON assembles a CompressedMasterJSON object from the |
| // provided MasterRequest. |
| func (s *Service) GetCompressedMasterJSON( |