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
0038f026
Commit
0038f026
authored
Feb 11, 2020
by
Dmitry Gruzd
Committed by
Dylan Griffith
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow-up refactoring from "Simplify es callbacks"
parent
70918025
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
ee/app/models/concerns/elastic/application_versioned_search.rb
...p/models/concerns/elastic/application_versioned_search.rb
+7
-9
No files found.
ee/app/models/concerns/elastic/application_versioned_search.rb
View file @
0038f026
...
...
@@ -19,6 +19,10 @@ module Elastic
self
.
project
&
.
use_elasticsearch?
end
def
maintaining_elasticsearch?
Gitlab
::
CurrentSettings
.
elasticsearch_indexing?
&&
self
.
searchable?
end
def
es_type
self
.
class
.
es_type
end
...
...
@@ -34,21 +38,17 @@ module Elastic
Elasticsearch
::
Model
::
Registry
.
add
(
self
)
if
self
.
is_a?
(
Class
)
if
self
<
ActiveRecord
::
Base
after_commit
:maintain_elasticsearch_create
,
on: :create
after_commit
:maintain_elasticsearch_update
,
on: :update
after_commit
:maintain_elasticsearch_destroy
,
on: :destroy
after_commit
:maintain_elasticsearch_create
,
on: :create
,
if: :maintaining_elasticsearch?
after_commit
:maintain_elasticsearch_update
,
on: :update
,
if: :maintaining_elasticsearch?
after_commit
:maintain_elasticsearch_destroy
,
on: :destroy
,
if: :maintaining_elasticsearch?
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
,
...
...
@@ -59,8 +59,6 @@ module Elastic
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
)
...
...
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