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
022ec748
Commit
022ec748
authored
Aug 17, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments addressed
parent
535aeb80
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
8 deletions
+28
-8
app/models/concerns/elastic/application_search.rb
app/models/concerns/elastic/application_search.rb
+6
-1
app/models/concerns/elastic/issues_search.rb
app/models/concerns/elastic/issues_search.rb
+4
-0
app/models/concerns/elastic/merge_requests_search.rb
app/models/concerns/elastic/merge_requests_search.rb
+4
-0
app/models/concerns/elastic/milestones_search.rb
app/models/concerns/elastic/milestones_search.rb
+4
-0
app/models/concerns/elastic/notes_search.rb
app/models/concerns/elastic/notes_search.rb
+4
-0
app/workers/elastic_indexer_worker.rb
app/workers/elastic_indexer_worker.rb
+6
-7
No files found.
app/models/concerns/elastic/application_search.rb
View file @
022ec748
...
...
@@ -60,11 +60,16 @@ module Elastic
end
def
es_parent
return
project_id
if
respond_to?
(
:project_id
)
project_id
if
respond_to?
(
:project_id
)
end
end
module
ClassMethods
# Should be overridden for all nested models
def
nested?
false
end
def
highlight_options
(
fields
)
es_fields
=
fields
.
map
{
|
field
|
field
.
split
(
'^'
).
first
}.
inject
({})
do
|
memo
,
field
|
memo
[
field
.
to_sym
]
=
{}
...
...
app/models/concerns/elastic/issues_search.rb
View file @
022ec748
...
...
@@ -33,6 +33,10 @@ module Elastic
data
end
def
self
.
nested?
true
end
def
self
.
elastic_search
(
query
,
options:
{})
if
query
=~
/#(\d+)\z/
query_hash
=
iid_query_hash
(
query_hash
,
$1
)
...
...
app/models/concerns/elastic/merge_requests_search.rb
View file @
022ec748
...
...
@@ -55,6 +55,10 @@ module Elastic
target_project_id
end
def
self
.
nested?
true
end
def
self
.
elastic_search
(
query
,
options:
{})
if
query
=~
/#(\d+)\z/
query_hash
=
iid_query_hash
(
query_hash
,
$1
)
...
...
app/models/concerns/elastic/milestones_search.rb
View file @
022ec748
...
...
@@ -22,6 +22,10 @@ module Elastic
)
end
def
self
.
nested?
true
end
def
self
.
elastic_search
(
query
,
options:
{})
options
[
:in
]
=
%w(title^2 description)
...
...
app/models/concerns/elastic/notes_search.rb
View file @
022ec748
...
...
@@ -40,6 +40,10 @@ module Elastic
data
end
def
self
.
nested?
true
end
def
self
.
elastic_search
(
query
,
options:
{})
options
[
:in
]
=
[
'note'
]
...
...
app/workers/elastic_indexer_worker.rb
View file @
022ec748
...
...
@@ -5,7 +5,6 @@ class ElasticIndexerWorker
sidekiq_options
queue: :elasticsearch
ISSUE_TRACKED_FIELDS
=
%w(assignee_id author_id confidential)
NOT_NESTED_ENTITIES
=
[
Project
,
PersonalSnippet
,
ProjectSnippet
,
Snippet
]
def
perform
(
operation
,
class_name
,
record_id
,
options
=
{})
klass
=
class_name
.
constantize
...
...
@@ -15,23 +14,23 @@ class ElasticIndexerWorker
record
=
klass
.
find
(
record_id
)
record
.
__elasticsearch__
.
client
=
client
if
NOT_NESTED_ENTITIES
.
include?
(
klass
)
record
.
__elasticsearch__
.
__send__
"
#{
operation
}
_document"
else
if
klass
.
nested?
record
.
__elasticsearch__
.
__send__
"
#{
operation
}
_document"
,
parent:
record
.
es_parent
else
record
.
__elasticsearch__
.
__send__
"
#{
operation
}
_document"
end
update_issue_notes
(
record
,
options
[
"changed_fields"
])
if
klass
==
Issue
when
/delete/
if
NOT_NESTED_ENTITIES
.
include?
(
klass
)
client
.
delete
index:
klass
.
index_name
,
type:
klass
.
document_type
,
id:
record_id
else
if
klass
.
nested?
client
.
delete
(
index:
klass
.
index_name
,
type:
klass
.
document_type
,
id:
record_id
,
parent:
options
[
"project_id"
]
)
else
client
.
delete
index:
klass
.
index_name
,
type:
klass
.
document_type
,
id:
record_id
end
clear_project_indexes
(
record_id
)
if
klass
==
Project
...
...
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