Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f2d21bea
Commit
f2d21bea
authored
Feb 11, 2020
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify elasticsearch maintenance callbacks
parent
fcc2bdb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
ee/app/models/concerns/elastic/application_versioned_search.rb
...p/models/concerns/elastic/application_versioned_search.rb
+29
-29
No files found.
ee/app/models/concerns/elastic/application_versioned_search.rb
View file @
f2d21bea
...
...
@@ -34,38 +34,38 @@ module Elastic
Elasticsearch
::
Model
::
Registry
.
add
(
self
)
if
self
.
is_a?
(
Class
)
if
self
<
ActiveRecord
::
Base
after_commit
on: :create
do
if
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:index
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
)
end
end
after_commit
on: :update
do
if
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:update
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
,
changed_fields:
self
.
previous_changes
.
keys
)
end
end
after_commit
on: :destroy
do
if
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:delete
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
,
es_parent:
self
.
es_parent
)
end
end
after_commit
:maintain_elasticsearch_create
,
on: :create
after_commit
:maintain_elasticsearch_update
,
on: :update
after_commit
:maintain_elasticsearch_destroy
,
on: :destroy
end
end
def
maintain_elasticsearch_create
return
unless
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:index
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
)
end
def
maintain_elasticsearch_update
return
unless
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:update
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
,
changed_fields:
self
.
previous_changes
.
keys
)
end
def
maintain_elasticsearch_destroy
return
unless
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
ElasticIndexerWorker
.
perform_async
(
:delete
,
self
.
class
.
to_s
,
self
.
id
,
self
.
es_id
,
es_parent:
self
.
es_parent
)
end
class_methods
do
def
__elasticsearch__
@__elasticsearch__
||=
::
Elastic
::
MultiVersionClassProxy
.
new
(
self
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment