diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-10 09:27:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 09:27:50 +0800 |
commit | 719bddcd76610a63dadc8555760072957a11cf30 (patch) | |
tree | 0df26092fba7e3e21444fe493e6b349473b6b0cb /routers/web/user/home.go | |
parent | fb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff) | |
download | gitea-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/user/home.go')
-rw-r--r-- | routers/web/user/home.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go index ca2705a42f..d3883571ed 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -16,6 +16,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/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" @@ -96,7 +97,7 @@ func Dashboard(ctx *context.Context) { } var err error - var mirrors []*models.Repository + var mirrors []*repo_model.Repository if ctxUser.IsOrganization() { var env models.AccessibleReposEnvironment if ctx.Org.Team != nil { @@ -114,7 +115,7 @@ func Dashboard(ctx *context.Context) { return } } else { - mirrors, err = models.GetUserMirrorRepositories(ctxUser.ID) + mirrors, err = repo_model.GetUserMirrorRepositories(ctxUser.ID) if err != nil { ctx.ServerError("GetUserMirrorRepositories", err) return @@ -122,7 +123,7 @@ func Dashboard(ctx *context.Context) { } ctx.Data["MaxShowRepoNum"] = setting.UI.User.RepoPagingNum - if err := models.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil { + if err := repo_model.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil { ctx.ServerError("MirrorRepositoryList.LoadAttributes", err) return } @@ -524,7 +525,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // showReposMap maps repository IDs to their Repository pointers. showReposMap, err := repoIDMap(ctxUser, issueCountByRepo, unitType) if err != nil { - if models.IsErrRepoNotExist(err) { + if repo_model.IsErrRepoNotExist(err) { ctx.NotFound("GetRepositoryByID", err) return } @@ -795,15 +796,15 @@ func issueIDsFromSearch(ctxUser *user_model.User, keyword string, opts *models.I return issueIDsFromSearch, nil } -func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*models.Repository, error) { - repoByID := make(map[int64]*models.Repository, len(issueCountByRepo)) +func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*repo_model.Repository, error) { + repoByID := make(map[int64]*repo_model.Repository, len(issueCountByRepo)) for id := range issueCountByRepo { if id <= 0 { continue } if _, ok := repoByID[id]; !ok { - repo, err := models.GetRepositoryByID(id) - if models.IsErrRepoNotExist(err) { + repo, err := repo_model.GetRepositoryByID(id) + if repo_model.IsErrRepoNotExist(err) { return nil, err } else if err != nil { return nil, fmt.Errorf("GetRepositoryByID: [%d]%v", id, err) |