diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-29 21:02:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-29 21:02:12 +0800 |
commit | 8ce1b539b1aaf242903b5b0c342dd592bd8da8d9 (patch) | |
tree | 455d363b51d69a9be4058961a16d5c43b7698f47 /models/repo_permission.go | |
parent | 8fa97a25f0dccc4db94d344ce7af632f8fe358b0 (diff) | |
download | gitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.tar.gz gitea-8ce1b539b1aaf242903b5b0c342dd592bd8da8d9.zip |
Use conditions but not repo ids as query condition (#16839)
* Use conditions but not repo ids as query condition
* Improve the performance of pulls/issue
* Remove duplicated code
* fix lint
* Fix bug
* Fix stats
* More fixes
* Fix build
* Fix lint
* Fix test
* Fix build
* Adjust the logic
* Merge
* Fix conflicts
* improve the performance
* Add comments for the query conditions functions
* Some improvements
Diffstat (limited to 'models/repo_permission.go')
-rw-r--r-- | models/repo_permission.go | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/models/repo_permission.go b/models/repo_permission.go index 45878c8ba4..40b63aa804 100644 --- a/models/repo_permission.go +++ b/models/repo_permission.go @@ -400,26 +400,6 @@ func HasAccess(userID int64, repo *repo_model.Repository) (bool, error) { return hasAccess(db.DefaultContext, userID, repo) } -// FilterOutRepoIdsWithoutUnitAccess filter out repos where user has no access to repositories -func FilterOutRepoIdsWithoutUnitAccess(u *user_model.User, repoIDs []int64, units ...unit.Type) ([]int64, error) { - i := 0 - for _, rID := range repoIDs { - repo, err := repo_model.GetRepositoryByID(rID) - if err != nil { - return nil, err - } - perm, err := GetUserRepoPermission(repo, u) - if err != nil { - return nil, err - } - if perm.CanReadAny(units...) { - repoIDs[i] = rID - i++ - } - } - return repoIDs[:i], nil -} - // GetRepoReaders returns all users that have explicit read access or higher to the repository. func GetRepoReaders(repo *repo_model.Repository) (_ []*user_model.User, err error) { return getUsersWithAccessMode(db.DefaultContext, repo, perm_model.AccessModeRead) |