Commit 1b2d12e7 authored by Valery Sizov's avatar Valery Sizov

Don't index newly created system messages and awards

parent 8a0ae304
......@@ -8,6 +8,7 @@ v 8.6.0 (unreleased)
- [Elastic] Update index on push to wiki
- [Elastic] Use subprocesses for ElasticSearch index jobs
- [Elastic] More accurate as_indexed_json (More stable database indexer)
- [Elastic] Fix: Don't index newly created system messages and awards
v 8.5.4
- [Elastic][Security] Notes exposure
......
......@@ -125,6 +125,10 @@ class Note < ActiveRecord::Base
end
end
def searchable?
!is_award && !system
end
def cross_reference?
system && SystemNoteService.cross_reference?(note)
end
......
......@@ -31,22 +31,27 @@ module Elastic
}
after_commit on: :create do
if Gitlab.config.elasticsearch.enabled
if Gitlab.config.elasticsearch.enabled && self.searchable?
ElasticIndexerWorker.perform_async(:index, self.class.to_s, self.id)
end
end
after_commit on: :update do
if Gitlab.config.elasticsearch.enabled
if Gitlab.config.elasticsearch.enabled && self.searchable?
ElasticIndexerWorker.perform_async(:update, self.class.to_s, self.id)
end
end
after_commit on: :destroy do
if Gitlab.config.elasticsearch.enabled
if Gitlab.config.elasticsearch.enabled && self.searchable?
ElasticIndexerWorker.perform_async(:delete, self.class.to_s, self.id)
end
end
# Should be overridden in the models where not eveything should be indexed
def searchable?
true
end
end
module ClassMethods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment