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

Side by Side Diff: appengine/cmd/milo/console/console.go

Issue 2196453002: Milo: Console view prototype (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fixes Created 4 years, 4 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
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package console
6
7 import (
8 "fmt"
9 "strings"
10
11 "github.com/luci/luci-go/appengine/cmd/milo/buildbot"
12 "github.com/luci/luci-go/appengine/cmd/milo/git"
13 "github.com/luci/luci-go/appengine/cmd/milo/resp"
14 "github.com/luci/luci-go/common/clock"
15 log "github.com/luci/luci-go/common/logging"
16 "golang.org/x/net/context"
17 )
18
19 func resolveBuilders(c context.Context, builderSpec []string) []resp.BuilderRef {
estaab 2016/08/04 23:21:24 what's the format of builderSpec? Should this be a
hinoka 2016/08/05 00:10:42 Oops dead code...
20 result := []resp.BuilderRef{}
21 for _, spec := range builderSpec {
22 j := strings.SplitN(spec, "/", 2)
23 result = append(result, resp.BuilderRef{
24 Module: j[0],
25 Name: j[1],
26 })
27 }
28 return result
29 }
30
31 // Returns results of build[commit_index][builder_index]
32 func GetConsoleBuilds(
33 c context.Context, module string,
34 builders []resp.BuilderRef, commits []string) (
35 [][]*resp.ConsoleBuild, error) {
36
37 switch module {
38 case "buildbot":
39 return buildbot.GetConsoleBuilds(c, builders, commits)
40 //case "buildbucket":
estaab 2016/08/04 23:21:24 remove commented code
hinoka 2016/08/05 00:10:42 Done.
41 // return buildbucket.getConsoleBuilds(c, builders, commits)
42 default:
43 panic(fmt.Errorf("Unrecognized module %s", module))
44 }
45 }
46
47 func console(c context.Context, def *ConsoleDef) (*resp.Console, error) {
estaab 2016/08/04 23:21:24 How much of this do you want to keep? I want to kn
hinoka 2016/08/05 00:10:42 Parts I'm keeping: * Interface between console/con
48 tStart := clock.Now(c)
49 // Lookup Commits. For this hack, we're just gonna hardcode src.git
50 commits, err := git.GetCommits(c, def.Repository, def.Branch)
51 if err != nil {
52 return nil, err
53 }
54 tGerrit := clock.Now(c)
nodir 2016/08/04 23:13:13 it is gitiles, not gerrit
hinoka 2016/08/05 00:10:42 Done.
55 log.Debugf(c, "Loading commits took %s.", tGerrit.Sub(tStart))
56 commitNames := make([]string, len(commits))
57 for i, commit := range commits {
58 commitNames[i] = commit.Revision
59 }
60
61 // HACK(hinoka): This only supports buildbot....
62 cb, err := GetConsoleBuilds(c, "buildbot", def.Builders, commitNames)
63 tConsole := clock.Now(c)
64 log.Debugf(c, "Loading the console took a total of %s.", tConsole.Sub(tG errit))
65 if err != nil {
66 return nil, err
67 }
68 ccb := make([]resp.CommitBuild, len(commits))
69 for i, commit := range commitNames {
70 // TODO(hinoka): Not like this
71 ccb[i].Commit = resp.Commit{Revision: commit}
72 ccb[i].Build = cb[i]
73 }
74
75 cs := &resp.Console{
76 Name: def.Name,
77 Commit: ccb,
78 BuilderRef: def.Builders,
79 }
80
81 return cs, nil
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698