1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 23:17:19 +00:00

Small refactor to reduce unnecessary database queries and remove duplicated functions (#33779)

This commit is contained in:
Lunny Xiao
2025-03-04 10:25:20 -08:00
committed by GitHub
parent 75e85c25c1
commit 6c8fb8d455
10 changed files with 32 additions and 12 deletions

View File

@@ -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)
}