aboutsummaryrefslogtreecommitdiffstats
path: root/modules/notification/indexer
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-09 03:15:35 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-12-08 14:15:35 -0500
commitbe06dee04ce46de2da222fc9b2be4fc3b68b816d (patch)
tree01dacbca7efd24412c7762b41d34f08afcca3e87 /modules/notification/indexer
parentbaf089e5b918fd967503e79022d3429b945359ef (diff)
downloadgitea-be06dee04ce46de2da222fc9b2be4fc3b68b816d.tar.gz
gitea-be06dee04ce46de2da222fc9b2be4fc3b68b816d.zip
Move code indexer related code to a new package (#9191)
* move code indexer related code to a new package * fix lint * fix tests * fix fmt * GetMaxID support interface parameter
Diffstat (limited to 'modules/notification/indexer')
-rw-r--r--modules/notification/indexer/indexer.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/notification/indexer/indexer.go b/modules/notification/indexer/indexer.go
index 13baa76ac0..0e76dde539 100644
--- a/modules/notification/indexer/indexer.go
+++ b/modules/notification/indexer/indexer.go
@@ -6,9 +6,11 @@ package indexer
import (
"code.gitea.io/gitea/models"
+ code_indexer "code.gitea.io/gitea/modules/indexer/code"
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
+ "code.gitea.io/gitea/modules/setting"
)
type indexerNotifier struct {
@@ -103,7 +105,21 @@ func (r *indexerNotifier) NotifyDeleteComment(doer *models.User, comment *models
func (r *indexerNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
issue_indexer.DeleteRepoIssueIndexer(repo)
- models.DeleteRepoFromIndexer(repo)
+ if setting.Indexer.RepoIndexerEnabled {
+ code_indexer.DeleteRepoFromIndexer(repo)
+ }
+}
+
+func (r *indexerNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
+ if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty {
+ code_indexer.UpdateRepoIndexer(repo)
+ }
+}
+
+func (r *indexerNotifier) NotifyPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *models.PushCommits) {
+ if setting.Indexer.RepoIndexerEnabled && refName == repo.DefaultBranch {
+ code_indexer.UpdateRepoIndexer(repo)
+ }
}
func (r *indexerNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) {