mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-04 00:01:16 -04:00
Compare commits
3 Commits
9f75b9a1a4
...
80ce48bef2
Author | SHA1 | Date | |
---|---|---|---|
|
80ce48bef2 | ||
|
29f084e495 | ||
|
d171273fd1 |
@ -62,6 +62,7 @@ func Projects(ctx *context.Context) {
|
||||
keyword := ctx.FormTrim("q")
|
||||
repo := ctx.Repo.Repository
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
ownerID := repo.OwnerID
|
||||
|
||||
ctx.Data["OpenCount"] = repo.NumOpenProjects
|
||||
ctx.Data["ClosedCount"] = repo.NumClosedProjects
|
||||
@ -73,21 +74,70 @@ func Projects(ctx *context.Context) {
|
||||
total = repo.NumClosedProjects
|
||||
}
|
||||
|
||||
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||
projects := make([]*project_model.Project, 0, total)
|
||||
|
||||
repoProjects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: setting.UI.IssuePagingNum,
|
||||
Page: page,
|
||||
},
|
||||
RepoID: repo.ID,
|
||||
IsClosed: optional.Some(isShowClosed),
|
||||
OrderBy: project_model.GetSearchOrderByBySortType(sortType),
|
||||
Type: project_model.TypeRepository,
|
||||
Title: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerError("GetRepoProjects", err)
|
||||
return
|
||||
}
|
||||
projects = append(projects, repoProjects...)
|
||||
|
||||
openOrgProjects, openCountForOrgProjects, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: setting.UI.IssuePagingNum,
|
||||
Page: page,
|
||||
},
|
||||
OwnerID: ownerID,
|
||||
IsClosed: optional.Some(false),
|
||||
OrderBy: project_model.GetSearchOrderByBySortType(sortType),
|
||||
Type: project_model.TypeOrganization,
|
||||
Title: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgProjects", err)
|
||||
return
|
||||
}
|
||||
|
||||
closeOrgProjects, closeCountForOrgProjects, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: setting.UI.IssuePagingNum,
|
||||
Page: page,
|
||||
},
|
||||
OwnerID: ownerID,
|
||||
IsClosed: optional.Some(true),
|
||||
OrderBy: project_model.GetSearchOrderByBySortType(sortType),
|
||||
Type: project_model.TypeOrganization,
|
||||
Title: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgProjects", err)
|
||||
return
|
||||
}
|
||||
|
||||
if isShowClosed {
|
||||
count += closeCountForOrgProjects
|
||||
total += int(closeCountForOrgProjects)
|
||||
projects = append(projects, closeOrgProjects...)
|
||||
} else {
|
||||
count += openCountForOrgProjects
|
||||
total += int(openCountForOrgProjects)
|
||||
projects = append(projects, openOrgProjects...)
|
||||
}
|
||||
|
||||
totalOpenCount := repo.NumOpenProjects + int(openCountForOrgProjects)
|
||||
totalCloseCount := repo.NumClosedProjects + int(closeCountForOrgProjects)
|
||||
ctx.Data["OpenCount"] = totalOpenCount
|
||||
ctx.Data["ClosedCount"] = totalCloseCount
|
||||
|
||||
if err := project_service.LoadIssueNumbersForProjects(ctx, projects, ctx.Doer); err != nil {
|
||||
ctx.ServerError("LoadIssueNumbersForProjects", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user