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
76dadf3d
Commit
76dadf3d
authored
May 02, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract project's indexing association as method
parent
d82412f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
ee/app/models/concerns/elastic/projects_search.rb
ee/app/models/concerns/elastic/projects_search.rb
+28
-0
ee/app/workers/elastic_indexer_worker.rb
ee/app/workers/elastic_indexer_worker.rb
+1
-7
No files found.
ee/app/models/concerns/elastic/projects_search.rb
View file @
76dadf3d
...
...
@@ -12,6 +12,14 @@ module Elastic
repository_access_level
)
.
freeze
INDEXED_ASSOCIATIONS
=
[
:issues
,
:merge_requests
,
:snippets
,
:notes
,
:milestones
].
freeze
included
do
include
ApplicationSearch
...
...
@@ -97,6 +105,26 @@ module Elastic
self
.
__elasticsearch__
.
search
(
query_hash
)
end
def
self
.
indexed_association_classes
INDEXED_ASSOCIATIONS
.
map
do
|
association_name
|
reflect_on_association
(
association_name
).
klass
end
end
def
each_indexed_association
INDEXED_ASSOCIATIONS
.
each
do
|
association_name
|
association
=
self
.
association
(
association_name
)
scope
=
association
.
scope
klass
=
association
.
klass
if
klass
==
Note
scope
=
scope
.
searchable
end
yield
klass
,
scope
end
end
end
end
end
ee/app/workers/elastic_indexer_worker.rb
View file @
76dadf3d
...
...
@@ -62,13 +62,7 @@ class ElasticIndexerWorker
end
def
initial_index_project
(
project
)
{
Issue
=>
project
.
issues
,
MergeRequest
=>
project
.
merge_requests
,
Snippet
=>
project
.
snippets
,
Note
=>
project
.
notes
.
searchable
,
Milestone
=>
project
.
milestones
}.
each
do
|
klass
,
objects
|
project
.
each_indexed_association
do
|
klass
,
objects
|
objects
.
find_each
{
|
object
|
import
(
:index
,
object
,
klass
)
}
end
...
...
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