From 9c645b54dcc3049a90de0c4d47c6efb0f8c1861d Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Wed, 15 Feb 2017 00:02:03 +0800
Subject: [PATCH] bug fixed on issues and pulls

---
 models/org.go        |  1 -
 routers/user/home.go | 29 +++++++++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/models/org.go b/models/org.go
index 2adfacdc8b..9fd81c1c0a 100644
--- a/models/org.go
+++ b/models/org.go
@@ -657,7 +657,6 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
 	}
 
 	repos := make([]*Repository, 0, len(repoIDs))
-
 	if len(repoIDs) <= 0 {
 		return repos, nil
 	}
diff --git a/routers/user/home.go b/routers/user/home.go
index 00c417cb91..4aa233b477 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -227,22 +227,35 @@ func Issues(ctx *context.Context) {
 			ctx.Handle(500, "GetRepositories", err)
 			return
 		}
+
+		for _, repo := range repos {
+			if (isPullList && repo.NumPulls == 0) ||
+				(!isPullList &&
+					(!repo.EnableUnit(models.UnitTypeIssues) || repo.NumIssues == 0)) {
+				continue
+			}
+
+			userRepoIDs = append(userRepoIDs, repo.ID)
+		}
+
+		if len(userRepoIDs) <= 0 {
+			userRepoIDs = []int64{-1}
+		}
+
 	} else {
 		if err := ctxUser.GetRepositories(1, ctx.User.NumRepos); err != nil {
 			ctx.Handle(500, "GetRepositories", err)
 			return
 		}
 		repos = ctxUser.Repos
-	}
 
-	for _, repo := range repos {
-		if (isPullList && repo.NumPulls == 0) ||
-			(!isPullList &&
-				(!repo.EnableUnit(models.UnitTypeIssues) || repo.NumIssues == 0)) {
-			continue
+		for _, repo := range repos {
+			if (isPullList && repo.NumPulls == 0) ||
+				(!isPullList &&
+					(!repo.EnableUnit(models.UnitTypeIssues) || repo.NumIssues == 0)) {
+				continue
+			}
 		}
-
-		userRepoIDs = append(userRepoIDs, repo.ID)
 	}
 
 	var issues []*models.Issue