summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-01-25 10:41:38 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-25 23:41:38 +0800
commitda1b6164fe3384a43cd440e54a8a2a10defc3553 (patch)
tree2bead467341f8ace417030333fc3ada52b936481 /routers/user
parent691fbdf1d362e77ab5eb2c42e51844b54a69b058 (diff)
downloadgitea-da1b6164fe3384a43cd440e54a8a2a10defc3553.tar.gz
gitea-da1b6164fe3384a43cd440e54a8a2a10defc3553.zip
Fix FIXME and remove superfluous queries in models/org (#749)
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go34
1 files changed, 27 insertions, 7 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index db2fe84f91..66ee6570c0 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -114,15 +114,20 @@ func Dashboard(ctx *context.Context) {
var err error
var repos, mirrors []*models.Repository
if ctxUser.IsOrganization() {
- repos, _, err = ctxUser.GetUserRepositories(ctx.User.ID, 1, setting.UI.User.RepoPagingNum)
+ env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
if err != nil {
- ctx.Handle(500, "GetUserRepositories", err)
+ ctx.Handle(500, "AccessibleReposEnv", err)
+ return
+ }
+ repos, err = env.Repos(1, setting.UI.User.RepoPagingNum)
+ if err != nil {
+ ctx.Handle(500, "env.Repos", err)
return
}
- mirrors, err = ctxUser.GetUserMirrorRepositories(ctx.User.ID)
+ mirrors, err = env.MirrorRepos()
if err != nil {
- ctx.Handle(500, "GetUserMirrorRepositories", err)
+ ctx.Handle(500, "env.MirrorRepos", err)
return
}
} else {
@@ -205,7 +210,12 @@ func Issues(ctx *context.Context) {
var err error
var repos []*models.Repository
if ctxUser.IsOrganization() {
- repos, _, err = ctxUser.GetUserRepositories(ctx.User.ID, 1, ctxUser.NumRepos)
+ env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
+ if err != nil {
+ ctx.Handle(500, "AccessibleReposEnv", err)
+ return
+ }
+ repos, err = env.Repos(1, ctxUser.NumRepos)
if err != nil {
ctx.Handle(500, "GetRepositories", err)
return
@@ -353,9 +363,19 @@ func showOrgProfile(ctx *context.Context) {
err error
)
if ctx.IsSigned && !ctx.User.IsAdmin {
- repos, count, err = org.GetUserRepositories(ctx.User.ID, page, setting.UI.User.RepoPagingNum)
+ env, err := org.AccessibleReposEnv(ctx.User.ID)
+ if err != nil {
+ ctx.Handle(500, "AccessibleReposEnv", err)
+ return
+ }
+ repos, err = env.Repos(page, setting.UI.User.RepoPagingNum)
+ if err != nil {
+ ctx.Handle(500, "env.Repos", err)
+ return
+ }
+ count, err = env.CountRepos()
if err != nil {
- ctx.Handle(500, "GetUserRepositories", err)
+ ctx.Handle(500, "env.CountRepos", err)
return
}
ctx.Data["Repos"] = repos