|
|
@ -214,48 +214,28 @@ func Issues(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// Get repositories.
|
|
|
|
// Get repositories.
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
var repos []*models.Repository
|
|
|
|
var userRepoIDs []int64
|
|
|
|
userRepoIDs := make([]int64, 0, len(repos))
|
|
|
|
|
|
|
|
if ctxUser.IsOrganization() {
|
|
|
|
if ctxUser.IsOrganization() {
|
|
|
|
env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
|
|
|
|
env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
ctx.Handle(500, "AccessibleReposEnv", err)
|
|
|
|
ctx.Handle(500, "AccessibleReposEnv", err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repos, err = env.Repos(1, ctxUser.NumRepos)
|
|
|
|
userRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
ctx.Handle(500, "GetRepositories", err)
|
|
|
|
ctx.Handle(500, "env.RepoIDs", err)
|
|
|
|
return
|
|
|
|
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 {
|
|
|
|
} else {
|
|
|
|
if err := ctxUser.GetRepositories(1, ctx.User.NumRepos); err != nil {
|
|
|
|
userRepoIDs, err = ctxUser.GetAccessRepoIDs()
|
|
|
|
ctx.Handle(500, "GetRepositories", err)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
ctx.Handle(500, "ctxUser.GetAccessRepoIDs", err)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repos = ctxUser.Repos
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, repo := range repos {
|
|
|
|
if len(userRepoIDs) <= 0 {
|
|
|
|
if (isPullList && repo.NumPulls == 0) ||
|
|
|
|
userRepoIDs = []int64{-1}
|
|
|
|
(!isPullList &&
|
|
|
|
|
|
|
|
(!repo.EnableUnit(models.UnitTypeIssues) || repo.NumIssues == 0)) {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var issues []*models.Issue
|
|
|
|
var issues []*models.Issue
|
|
|
@ -309,55 +289,41 @@ func Issues(ctx *context.Context) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showRepos := make([]*models.Repository, 0, len(issues))
|
|
|
|
showRepos, err := models.IssueList(issues).LoadRepositories()
|
|
|
|
showReposSet := make(map[int64]bool)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
ctx.Handle(500, "LoadRepositories", fmt.Errorf("%v", err))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if repoID > 0 {
|
|
|
|
if repoID > 0 {
|
|
|
|
repo, err := models.GetRepositoryByID(repoID)
|
|
|
|
var theRepo *models.Repository
|
|
|
|
if err != nil {
|
|
|
|
for _, repo := range showRepos {
|
|
|
|
ctx.Handle(500, "GetRepositoryByID", fmt.Errorf("[#%d]%v", repoID, err))
|
|
|
|
if repo.ID == repoID {
|
|
|
|
return
|
|
|
|
theRepo = repo
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err = repo.GetOwner(); err != nil {
|
|
|
|
if theRepo == nil {
|
|
|
|
ctx.Handle(500, "GetOwner", fmt.Errorf("[#%d]%v", repoID, err))
|
|
|
|
theRepo, err = models.GetRepositoryByID(repoID)
|
|
|
|
return
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
ctx.Handle(500, "GetRepositoryByID", fmt.Errorf("[#%d]%v", repoID, err))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
showRepos = append(showRepos, theRepo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if user has access to given repository.
|
|
|
|
// Check if user has access to given repository.
|
|
|
|
if !repo.IsOwnedBy(ctxUser.ID) && !repo.HasAccess(ctxUser) {
|
|
|
|
if !theRepo.IsOwnedBy(ctxUser.ID) && !theRepo.HasAccess(ctxUser) {
|
|
|
|
ctx.Handle(404, "Issues", fmt.Errorf("#%d", repoID))
|
|
|
|
ctx.Handle(404, "Issues", fmt.Errorf("#%d", repoID))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showReposSet[repoID] = true
|
|
|
|
|
|
|
|
showRepos = append(showRepos, repo)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, issue := range issues {
|
|
|
|
err = models.RepositoryList(showRepos).LoadAttributes()
|
|
|
|
// Get Repository data.
|
|
|
|
if err != nil {
|
|
|
|
issue.Repo, err = models.GetRepositoryByID(issue.RepoID)
|
|
|
|
ctx.Handle(500, "LoadAttributes", fmt.Errorf("%v", err))
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
ctx.Handle(500, "GetRepositoryByID", fmt.Errorf("[#%d]%v", issue.RepoID, err))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get Owner data.
|
|
|
|
|
|
|
|
if err = issue.Repo.GetOwner(); err != nil {
|
|
|
|
|
|
|
|
ctx.Handle(500, "GetOwner", fmt.Errorf("[#%d]%v", issue.RepoID, err))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Append repo to list of shown repos
|
|
|
|
|
|
|
|
if filterMode == models.FilterModeAll {
|
|
|
|
|
|
|
|
// Use a map to make sure we don't add the same Repository twice.
|
|
|
|
|
|
|
|
_, ok := showReposSet[issue.RepoID]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
showReposSet[issue.RepoID] = true
|
|
|
|
|
|
|
|
// Append to list of shown Repositories.
|
|
|
|
|
|
|
|
showRepos = append(showRepos, issue.Repo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
issueStats := models.GetUserIssueStats(repoID, ctxUser.ID, userRepoIDs, filterMode, isPullList)
|
|
|
|
issueStats := models.GetUserIssueStats(repoID, ctxUser.ID, userRepoIDs, filterMode, isPullList)
|
|
|
|