mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
This commit is contained in:
@@ -38,7 +38,7 @@ func getDefaultBranchSha(ctx context.Context, repo *repo_model.Repository) (stri
|
||||
|
||||
// getRepoChanges returns changes to repo since last indexer update
|
||||
func getRepoChanges(ctx context.Context, repo *repo_model.Repository, revision string) (*repoChanges, error) {
|
||||
status, err := repo_model.GetIndexerStatus(repo, repo_model.RepoIndexerTypeCode)
|
||||
status, err := repo_model.GetIndexerStatus(ctx, repo, repo_model.RepoIndexerTypeCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -108,7 +108,7 @@ func index(ctx context.Context, indexer Indexer, repoID int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return repo_model.UpdateIndexerStatus(repo, repo_model.RepoIndexerTypeCode, sha)
|
||||
return repo_model.UpdateIndexerStatus(ctx, repo, repo_model.RepoIndexerTypeCode, sha)
|
||||
}
|
||||
|
||||
// Init initialize the repo indexer
|
||||
|
@@ -362,7 +362,7 @@ func UpdateIssueIndexer(issue *models.Issue) {
|
||||
// DeleteRepoIssueIndexer deletes repo's all issues indexes
|
||||
func DeleteRepoIssueIndexer(repo *repo_model.Repository) {
|
||||
var ids []int64
|
||||
ids, err := models.GetIssueIDsByRepoID(repo.ID)
|
||||
ids, err := models.GetIssueIDsByRepoID(db.DefaultContext, repo.ID)
|
||||
if err != nil {
|
||||
log.Error("getIssueIDsByRepoID failed: %v", err)
|
||||
return
|
||||
|
@@ -30,7 +30,7 @@ func (db *DBIndexer) Index(id int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
status, err := repo_model.GetIndexerStatus(repo, repo_model.RepoIndexerTypeStats)
|
||||
status, err := repo_model.GetIndexerStatus(ctx, repo, repo_model.RepoIndexerTypeStats)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
@@ -49,7 +50,7 @@ func TestRepoStatsIndex(t *testing.T) {
|
||||
|
||||
queue.GetManager().FlushAll(context.Background(), 5*time.Second)
|
||||
|
||||
status, err := repo_model.GetIndexerStatus(repo, repo_model.RepoIndexerTypeStats)
|
||||
status, err := repo_model.GetIndexerStatus(db.DefaultContext, repo, repo_model.RepoIndexerTypeStats)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.CommitSha)
|
||||
langs, err := repo_model.GetTopLanguageStats(repo, 5)
|
||||
|
Reference in New Issue
Block a user