aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/explore
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /routers/web/explore
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'routers/web/explore')
-rw-r--r--routers/web/explore/code.go9
-rw-r--r--routers/web/explore/repo.go3
2 files changed, 7 insertions, 5 deletions
diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go
index 6ff48be0f8..b61f25a96c 100644
--- a/routers/web/explore/code.go
+++ b/routers/web/explore/code.go
@@ -8,6 +8,7 @@ import (
"net/http"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -69,16 +70,16 @@ func Code(ctx *context.Context) {
// if non-admin login user, we need check UnitTypeCode at first
if ctx.User != nil && len(repoIDs) > 0 {
- repoMaps, err := models.GetRepositoriesMapByIDs(repoIDs)
+ repoMaps, err := repo_model.GetRepositoriesMapByIDs(repoIDs)
if err != nil {
ctx.ServerError("SearchResults", err)
return
}
- var rightRepoMap = make(map[int64]*models.Repository, len(repoMaps))
+ var rightRepoMap = make(map[int64]*repo_model.Repository, len(repoMaps))
repoIDs = make([]int64, 0, len(repoMaps))
for id, repo := range repoMaps {
- if repo.CheckUnitUser(ctx.User, unit.TypeCode) {
+ if models.CheckRepoUnitUser(repo, ctx.User, unit.TypeCode) {
rightRepoMap[id] = repo
repoIDs = append(repoIDs, id)
}
@@ -113,7 +114,7 @@ func Code(ctx *context.Context) {
}
}
- repoMaps, err := models.GetRepositoriesMapByIDs(loadRepoIDs)
+ repoMaps, err := repo_model.GetRepositoriesMapByIDs(loadRepoIDs)
if err != nil {
ctx.ServerError("SearchResults", err)
return
diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go
index a81386b5fd..0a78e9e29d 100644
--- a/routers/web/explore/repo.go
+++ b/routers/web/explore/repo.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
@@ -36,7 +37,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
}
var (
- repos []*models.Repository
+ repos []*repo_model.Repository
count int64
err error
orderBy db.SearchOrderBy