mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Small refactor to reduce unnecessary database queries and remove duplicated functions (#33779)
This commit is contained in:
@@ -839,6 +839,9 @@ func GetRepositoryByID(ctx context.Context, id int64) (*Repository, error) {
|
||||
// GetRepositoriesMapByIDs returns the repositories by given id slice.
|
||||
func GetRepositoriesMapByIDs(ctx context.Context, ids []int64) (map[int64]*Repository, error) {
|
||||
repos := make(map[int64]*Repository, len(ids))
|
||||
if len(ids) == 0 {
|
||||
return repos, nil
|
||||
}
|
||||
return repos, db.GetEngine(ctx).In("id", ids).Find(&repos)
|
||||
}
|
||||
|
||||
|
@@ -21,11 +21,6 @@ import (
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
// FindReposMapByIDs find repos as map
|
||||
func FindReposMapByIDs(ctx context.Context, repoIDs []int64, res map[int64]*Repository) error {
|
||||
return db.GetEngine(ctx).In("id", repoIDs).Find(&res)
|
||||
}
|
||||
|
||||
// RepositoryListDefaultPageSize is the default number of repositories
|
||||
// to load in memory when running administrative tasks on all (or almost
|
||||
// all) of them.
|
||||
|
Reference in New Issue
Block a user