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

Side by Side Diff: milo/appengine/frontend/frontpage.go

Issue 2801463002: Milo: Use custom config caching layer (Closed)
Patch Set: Review: Remove double logging Created 3 years, 8 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 frontend 5 package frontend
6 6
7 import ( 7 import (
8 "net/http"
9
10 "github.com/luci/luci-go/server/router" 8 "github.com/luci/luci-go/server/router"
11 "github.com/luci/luci-go/server/templates" 9 "github.com/luci/luci-go/server/templates"
12 10
13 "github.com/luci/luci-go/common/sync/parallel" 11 "github.com/luci/luci-go/common/sync/parallel"
14 "github.com/luci/luci-go/milo/api/resp" 12 "github.com/luci/luci-go/milo/api/resp"
15 "github.com/luci/luci-go/milo/appengine/buildbot" 13 "github.com/luci/luci-go/milo/appengine/buildbot"
16 "github.com/luci/luci-go/milo/appengine/buildbucket" 14 "github.com/luci/luci-go/milo/appengine/buildbucket"
17 "github.com/luci/luci-go/milo/appengine/common" 15 "github.com/luci/luci-go/milo/appengine/common"
18 ) 16 )
19 17
20 func frontpageHandler(c *router.Context) { 18 func frontpageHandler(c *router.Context) {
21 fp := resp.FrontPage{} 19 fp := resp.FrontPage{}
22 var mBuildbot, mBuildbucket *resp.CIService 20 var mBuildbot, mBuildbucket *resp.CIService
23 21
24 err := parallel.FanOutIn(func(ch chan<- func() error) { 22 err := parallel.FanOutIn(func(ch chan<- func() error) {
25 ch <- func() (err error) { 23 ch <- func() (err error) {
26 mBuildbot, err = buildbot.GetAllBuilders(c.Context) 24 mBuildbot, err = buildbot.GetAllBuilders(c.Context)
27 return err 25 return err
28 } 26 }
29 ch <- func() (err error) { 27 ch <- func() (err error) {
30 mBuildbucket, err = buildbucket.GetAllBuilders(c.Context ) 28 mBuildbucket, err = buildbucket.GetAllBuilders(c.Context )
31 return err 29 return err
32 } 30 }
33 }) 31 })
34 if err != nil {
35 common.ErrorPage(c, http.StatusInternalServerError, err.Error())
36 return
37 }
38 32
39 fp.CIServices = append(fp.CIServices, *mBuildbucket) 33 fp.CIServices = append(fp.CIServices, *mBuildbucket)
40 fp.CIServices = append(fp.CIServices, *mBuildbot) 34 fp.CIServices = append(fp.CIServices, *mBuildbot)
41 templates.MustRender(c.Context, c.Writer, "pages/frontpage.html", templa tes.Args{ 35 templates.MustRender(c.Context, c.Writer, "pages/frontpage.html", templa tes.Args{
42 "frontpage": fp, 36 "frontpage": fp,
37 "error": err.Error(),
43 }) 38 })
44 } 39 }
45 40
46 func frontpageTestData() []common.TestBundle { 41 func frontpageTestData() []common.TestBundle {
47 data := &templates.Args{ 42 data := &templates.Args{
48 "frontpage": resp.FrontPage{ 43 "frontpage": resp.FrontPage{
49 CIServices: []resp.CIService{ 44 CIServices: []resp.CIService{
50 { 45 {
51 Name: "Module 1", 46 Name: "Module 1",
52 BuilderGroups: []resp.BuilderGroup{ 47 BuilderGroups: []resp.BuilderGroup{
53 { 48 {
54 Name: "Example master A" , 49 Name: "Example master A" ,
55 Builders: []resp.Link{ 50 Builders: []resp.Link{
56 { 51 {
57 Label: " Example builder", 52 Label: " Example builder",
58 URL: " /master1/buildera", 53 URL: " /master1/buildera",
59 }, 54 },
60 { 55 {
61 Label: " Example builder 2", 56 Label: " Example builder 2",
62 URL: " /master1/builderb", 57 URL: " /master1/builderb",
63 }, 58 },
64 }, 59 },
65 }, 60 },
66 }, 61 },
67 }, 62 },
68 }, 63 },
69 }, 64 },
65 "error": "couldn't find ice cream",
70 } 66 }
71 return []common.TestBundle{ 67 return []common.TestBundle{
72 { 68 {
73 Description: "Basic frontpage", 69 Description: "Basic frontpage",
74 Data: *data, 70 Data: *data,
75 }, 71 },
76 } 72 }
77 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698