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

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

Issue 2801463002: Milo: Use custom config caching layer (Closed)
Patch Set: Working 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 "errors": err.Error(),
nodir 2017/04/04 23:12:08 this looks like one error, a string. Why it is cal
hinoka 2017/04/05 20:45:07 Done.
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{
(...skipping 15 matching lines...) Expand all
68 }, 63 },
69 }, 64 },
70 } 65 }
71 return []common.TestBundle{ 66 return []common.TestBundle{
72 { 67 {
73 Description: "Basic frontpage", 68 Description: "Basic frontpage",
74 Data: *data, 69 Data: *data,
75 }, 70 },
76 } 71 }
77 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698