From 8ce1b539b1aaf242903b5b0c342dd592bd8da8d9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 29 Dec 2021 21:02:12 +0800 Subject: 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 --- models/repo_permission.go | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'models/repo_permission.go') 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) -- cgit v1.2.3