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

Unified Diff: milo/frontend/view_console.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: Created 3 years, 5 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
« milo/common/model/build_summary.go ('K') | « milo/common/model/build_summary.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/frontend/view_console.go
diff --git a/milo/frontend/view_console.go b/milo/frontend/view_console.go
index b314fecf4da2344e12e9c1cf6b90ce0fe4af5e84..465e5560e651852275c0a3e073f7315751c94048 100644
--- a/milo/frontend/view_console.go
+++ b/milo/frontend/view_console.go
@@ -15,13 +15,13 @@
package frontend
import (
+ "encoding/hex"
"fmt"
"net/http"
"strings"
"golang.org/x/net/context"
- "github.com/luci/luci-go/common/api/gitiles"
"github.com/luci/luci-go/common/clock"
"github.com/luci/luci-go/common/errors"
"github.com/luci/luci-go/common/logging"
@@ -30,18 +30,12 @@ import (
"github.com/luci/luci-go/milo/api/config"
"github.com/luci/luci-go/milo/api/resp"
+ "github.com/luci/luci-go/milo/buildsource"
"github.com/luci/luci-go/milo/common"
"github.com/luci/luci-go/milo/common/model"
+ "github.com/luci/luci-go/milo/git"
)
-// Returns results of build[commit_index][builder_index]
-func getConsoleBuilds(
- c context.Context, builders []resp.BuilderRef, commits []string) (
- [][]*model.BuildSummary, error) {
-
- panic("Nothing to see here, check back later.")
-}
-
// getConsoleDef finds the console definition as defined by any project.
// If the user is not a reader of the project, this will return a 404.
// TODO(hinoka): If the user is not a reader of any of of the builders returned,
@@ -73,33 +67,36 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
if err != nil {
return nil, err
}
- commits, err := getCommits(c, def.RepoURL, def.Branch, 25)
+ commitInfo, err := git.GetHistory(c, def.RepoURL, def.Branch, 25)
if err != nil {
return nil, err
}
tGitiles := clock.Now(c)
logging.Debugf(c, "Loading commits took %s.", tGitiles.Sub(tStart))
- commitNames := make([]string, len(commits))
- commitLinks := make([]*resp.Link, len(commits))
- for i, commit := range commits {
- commitNames[i] = commit.Revision.Label
- commitLinks[i] = commit.Revision
+ commitNames := make([]string, len(commitInfo.Commits))
+ commitLinks := make([]*resp.Link, len(commitInfo.Commits))
+ for i, commit := range commitInfo.Commits {
+ commitS := hex.EncodeToString(commit.Hash)
+ commitNames[i] = commitS
+ commitLinks[i] = resp.NewLink(commitS, def.RepoURL+"/+/"+commitS)
}
// HACK(hinoka): This only supports buildbot....
Ryan Tseng 2017/07/19 08:07:58 no longer~
iannucci 2017/07/20 00:14:56 Done.
+ builderNames := make([]string, len(def.Builders))
builders := make([]resp.BuilderRef, len(def.Builders))
for i, b := range def.Builders {
+ builderNames[i] = b.Name
builders[i] = resp.BuilderRef{
b.Name, strings.Split(b.Category, "|"), b.ShortName,
}
}
- cb, err := getConsoleBuilds(c, builders, commitNames)
+ cb, err := buildsource.GetBuildSummariesForConsole(c, project, def, commitNames, builderNames)
tConsole := clock.Now(c)
logging.Debugf(c, "Loading the console took a total of %s.", tConsole.Sub(tGitiles))
if err != nil {
return nil, err
}
- ccb := make([]resp.CommitBuild, len(commits))
+ ccb := make([]resp.CommitBuild, len(commitNames))
for i, commit := range commitLinks {
// TODO(hinoka): Not like this
ccb[i].Commit = resp.Commit{Revision: commit}
@@ -115,27 +112,6 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
return cs, nil
}
-func getCommits(c context.Context, repoURL, treeish string, limit int) ([]resp.Commit, error) {
- commits, err := gitiles.Log(c, repoURL, treeish, limit)
- if err != nil {
- return nil, err
- }
- result := make([]resp.Commit, len(commits))
- for i, log := range commits {
- result[i] = resp.Commit{
- AuthorName: log.Author.Name,
- AuthorEmail: log.Author.Email,
- Repo: repoURL,
- Revision: resp.NewLink(log.Commit, repoURL+"/+/"+log.Commit),
- Description: log.Message,
- Title: strings.SplitN(log.Message, "\n", 2)[0],
- // TODO(hinoka): Fill in the rest of resp.Commit and add those details
- // in the html.
- }
- }
- return result, nil
-}
-
// ConsoleHandler renders the console page.
func ConsoleHandler(c *router.Context) {
project := c.Params.ByName("project")
« milo/common/model/build_summary.go ('K') | « milo/common/model/build_summary.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698