aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-06 16:01:49 +0800
committerGitHub <noreply@github.com>2022-06-06 16:01:49 +0800
commit26095115f4ae90e3fdc6ab695978efd16e317f75 (patch)
tree92ec1c7ff54e0a65f4f0662baa8c0244dd9f324b /routers/web/user
parentebeb6e7c71a0c763b52153f4eb427e7c5b89a95e (diff)
downloadgitea-26095115f4ae90e3fdc6ab695978efd16e317f75.tar.gz
gitea-26095115f4ae90e3fdc6ab695978efd16e317f75.zip
Move some repository related code into sub package (#19711)
* Move some repository related code into sub package * Move more repository functions out of models * Fix lint * Some performance optimization for webhooks and others * some refactors * Fix lint * Fix * Update modules/repository/delete.go Co-authored-by: delvh <dev.lh@web.de> * Fix test * Merge * Fix test * Fix test * Fix test * Fix test Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'routers/web/user')
-rw-r--r--routers/web/user/home.go10
-rw-r--r--routers/web/user/home_test.go4
-rw-r--r--routers/web/user/package.go3
-rw-r--r--routers/web/user/profile.go6
-rw-r--r--routers/web/user/setting/profile.go5
5 files changed, 13 insertions, 15 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 1412f6cfef..9b4fc652f1 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -166,7 +166,7 @@ func Milestones(ctx *context.Context) {
return
}
- repoOpts := models.SearchRepoOptions{
+ repoOpts := repo_model.SearchRepoOptions{
Actor: ctxUser,
OwnerID: ctxUser.ID,
Private: true,
@@ -181,7 +181,7 @@ func Milestones(ctx *context.Context) {
}
var (
- userRepoCond = models.SearchRepositoryCondition(&repoOpts) // all repo condition user could visit
+ userRepoCond = repo_model.SearchRepositoryCondition(&repoOpts) // all repo condition user could visit
repoCond = userRepoCond
repoIDs []int64
@@ -234,7 +234,7 @@ func Milestones(ctx *context.Context) {
return
}
- showRepos, _, err := models.SearchRepositoryByCondition(&repoOpts, userRepoCond, false)
+ showRepos, _, err := repo_model.SearchRepositoryByCondition(&repoOpts, userRepoCond, false)
if err != nil {
ctx.ServerError("SearchRepositoryByCondition", err)
return
@@ -437,7 +437,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
// As team:
// - Team org's owns the repository.
// - Team has read permission to repository.
- repoOpts := &models.SearchRepoOptions{
+ repoOpts := &repo_model.SearchRepoOptions{
Actor: ctx.Doer,
OwnerID: ctx.Doer.ID,
Private: true,
@@ -559,7 +559,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
}
// a RepositoryList
- showRepos := models.RepositoryListOfMap(showReposMap)
+ showRepos := repo_model.RepositoryListOfMap(showReposMap)
sort.Sort(showRepos)
// maps pull request IDs to their CommitStatus. Will be posted to ctx.Data.
diff --git a/routers/web/user/home_test.go b/routers/web/user/home_test.go
index bf78e00ada..9ad0711dc0 100644
--- a/routers/web/user/home_test.go
+++ b/routers/web/user/home_test.go
@@ -8,7 +8,7 @@ import (
"net/http"
"testing"
- "code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
@@ -26,7 +26,7 @@ func TestArchivedIssues(t *testing.T) {
ctx.Req.Form.Set("state", "open")
// Assume: User 30 has access to two Repos with Issues, one of the Repos being archived.
- repos, _, _ := models.GetUserRepositories(&models.SearchRepoOptions{Actor: ctx.Doer})
+ repos, _, _ := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{Actor: ctx.Doer})
assert.Len(t, repos, 2)
IsArchived := make(map[int64]bool)
NumIssues := make(map[int64]int)
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index c9aa2471ef..b2b550cb73 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -7,7 +7,6 @@ package user
import (
"net/http"
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
packages_model "code.gitea.io/gitea/models/packages"
container_model "code.gitea.io/gitea/models/packages/container"
@@ -288,7 +287,7 @@ func PackageSettings(ctx *context.Context) {
ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["PackageDescriptor"] = pd
- repos, _, _ := models.GetUserRepositories(&models.SearchRepoOptions{
+ repos, _, _ := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{
Actor: pd.Owner,
Private: true,
})
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 8bce5460cc..44501fc245 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -195,7 +195,7 @@ func Profile(ctx *context.Context) {
}
case "stars":
ctx.Data["PageIsProfileStarList"] = true
- repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ repos, count, err = repo_model.SearchRepository(&repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
PageSize: setting.UI.User.RepoPagingNum,
Page: page,
@@ -227,7 +227,7 @@ func Profile(ctx *context.Context) {
return
}
case "watching":
- repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ repos, count, err = repo_model.SearchRepository(&repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
PageSize: setting.UI.User.RepoPagingNum,
Page: page,
@@ -249,7 +249,7 @@ func Profile(ctx *context.Context) {
total = int(count)
default:
- repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
+ repos, count, err = repo_model.SearchRepository(&repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
PageSize: setting.UI.User.RepoPagingNum,
Page: page,
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index c2a406b184..972271269f 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -15,7 +15,6 @@ import (
"path/filepath"
"strings"
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
@@ -304,7 +303,7 @@ func Repos(ctx *context.Context) {
return
}
- userRepos, _, err := models.GetUserRepositories(&models.SearchRepoOptions{
+ userRepos, _, err := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{
Actor: ctxUser,
Private: true,
ListOptions: db.ListOptions{
@@ -329,7 +328,7 @@ func Repos(ctx *context.Context) {
ctx.Data["Dirs"] = repoNames
ctx.Data["ReposMap"] = repos
} else {
- repos, count64, err := models.GetUserRepositories(&models.SearchRepoOptions{Actor: ctxUser, Private: true, ListOptions: opts})
+ repos, count64, err := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{Actor: ctxUser, Private: true, ListOptions: opts})
if err != nil {
ctx.ServerError("GetUserRepositories", err)
return