diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-20 22:08:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 22:08:52 +0800 |
commit | fd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch) | |
tree | 50038348ec10485f72344f3ac80324e04abc1283 /modules/indexer | |
parent | d81e31ad7826a81fc7139f329f250594610a274b (diff) | |
download | gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip |
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
Diffstat (limited to 'modules/indexer')
-rw-r--r-- | modules/indexer/code/git.go | 2 | ||||
-rw-r--r-- | modules/indexer/code/indexer.go | 2 | ||||
-rw-r--r-- | modules/indexer/issues/indexer.go | 2 | ||||
-rw-r--r-- | modules/indexer/stats/db.go | 2 | ||||
-rw-r--r-- | modules/indexer/stats/indexer_test.go | 3 |
5 files changed, 6 insertions, 5 deletions
diff --git a/modules/indexer/code/git.go b/modules/indexer/code/git.go index 60018af20c..66d76377ad 100644 --- a/modules/indexer/code/git.go +++ b/modules/indexer/code/git.go @@ -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 } diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index f15b8d8651..9845ade3dd 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -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 diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go index d4df4f8a4f..7adc938dcc 100644 --- a/modules/indexer/issues/indexer.go +++ b/modules/indexer/issues/indexer.go @@ -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 diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go index bb3385ab63..d39b1dcf2a 100644 --- a/modules/indexer/stats/db.go +++ b/modules/indexer/stats/db.go @@ -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 } diff --git a/modules/indexer/stats/indexer_test.go b/modules/indexer/stats/indexer_test.go index c8bd8d1783..9d9de5413c 100644 --- a/modules/indexer/stats/indexer_test.go +++ b/modules/indexer/stats/indexer_test.go @@ -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) |