package main import ( "fagott.pw/grilist/grilist" "github.com/julienschmidt/httprouter" "log" "net/http" "sync" "time" ) func viewDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { user, _ := app.Charakterin.GetUserFromRequest(r) var categories []grilist.DashboardCategory t1 := time.Now() var wg sync.WaitGroup for _, module := range app.Modules { wg.Add(1) go func(module grilist.Module) { t2 := time.Now() for _, category := range module.ProvideDashboardData(user) { if len(category.Cards) > 0 { categories = append(categories, category) } } log.Printf("%s dashboard_data: %dms", module.Name(), time.Since(t2).Nanoseconds()/1000000) wg.Done() }(module) } wg.Wait() log.Printf("dashboard_data: %dms", time.Since(t1).Nanoseconds()/1000000) data := make(map[string]interface{}) data["categories"] = categories data["user"] = user app.Renderer.RenderPage("dashboard", w, data) }