mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 13:39:19 -05:00
Merge pull request '[v7.0/forgejo] Fix SQL command with too many placeholders' (#3578) from bp-v7.0/forgejo-33cd844-0d029eb into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3578 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
6069fcced6
4 changed files with 16 additions and 0 deletions
|
@ -120,6 +120,9 @@ func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, err
|
|||
}
|
||||
|
||||
func FindBranchesByRepoAndBranchName(ctx context.Context, repoBranches map[int64]string) (map[int64]string, error) {
|
||||
if len(repoBranches) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
cond := builder.NewCond()
|
||||
for repoID, branchName := range repoBranches {
|
||||
cond = cond.Or(builder.And(builder.Eq{"repo_id": repoID}, builder.Eq{"name": branchName}))
|
||||
|
|
|
@ -183,3 +183,12 @@ func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.NotNil(t, deletedBranch)
|
||||
}
|
||||
|
||||
func TestFindBranchesByRepoAndBranchName(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
// With no repos or branches given, we find no branches.
|
||||
branches, err := git_model.FindBranchesByRepoAndBranchName(db.DefaultContext, map[int64]string{})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, branches, 0)
|
||||
}
|
||||
|
|
1
release-notes/8.0.0/fix/3570.md
Normal file
1
release-notes/8.0.0/fix/3570.md
Normal file
|
@ -0,0 +1 @@
|
|||
Fixed an issue that resulted in excessive and unnecessary database queries when a user with no repositories was viewing their dashboard.
|
|
@ -120,6 +120,9 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato
|
|||
|
||||
// FindReposLastestCommitStatuses loading repository default branch latest combinded commit status with cache
|
||||
func FindReposLastestCommitStatuses(ctx context.Context, repos []*repo_model.Repository) ([]*git_model.CommitStatus, error) {
|
||||
if len(repos) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
results := make([]*git_model.CommitStatus, len(repos))
|
||||
for i, repo := range repos {
|
||||
if cv := getCommitStatusCache(repo.ID, repo.DefaultBranch); cv != nil {
|
||||
|
|
Loading…
Reference in a new issue