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
7934e400
Commit
7934e400
authored
Apr 04, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue assignees] Elasticsearch for multiple assignees in issue
parent
aba54cae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
4 deletions
+33
-4
app/models/concerns/elastic/issues_search.rb
app/models/concerns/elastic/issues_search.rb
+10
-1
app/models/concerns/elastic/notes_search.rb
app/models/concerns/elastic/notes_search.rb
+1
-1
app/models/issue_assignee.rb
app/models/issue_assignee.rb
+18
-0
app/workers/elastic_indexer_worker.rb
app/workers/elastic_indexer_worker.rb
+1
-1
spec/models/concerns/elastic/issue_spec.rb
spec/models/concerns/elastic/issue_spec.rb
+3
-1
No files found.
app/models/concerns/elastic/issues_search.rb
View file @
7934e400
...
...
@@ -17,7 +17,14 @@ module Elastic
indexes
:state
,
type: :text
indexes
:project_id
,
type: :integer
indexes
:author_id
,
type: :integer
# The field assignee_id does not exist in issues table anymore.
# Nevertheless we'll keep this field as is because we don't want users to rebuild index
# + the ES treats arrays transparently so
# to any integer field you can write any array of integers and you don't have to change mapping.
# More over you can query those items just like a single integer value.
indexes
:assignee_id
,
type: :integer
indexes
:confidential
,
type: :boolean
end
...
...
@@ -26,10 +33,12 @@ module Elastic
# We don't use as_json(only: ...) because it calls all virtual and serialized attributtes
# https://gitlab.com/gitlab-org/gitlab-ee/issues/349
[
:id
,
:iid
,
:title
,
:description
,
:created_at
,
:updated_at
,
:state
,
:project_id
,
:author_id
,
:
assignee_id
,
:
confidential
].
each
do
|
attr
|
[
:id
,
:iid
,
:title
,
:description
,
:created_at
,
:updated_at
,
:state
,
:project_id
,
:author_id
,
:confidential
].
each
do
|
attr
|
data
[
attr
.
to_s
]
=
safely_read_attribute_for_elasticsearch
(
attr
)
end
data
[
'assignee_id'
]
=
safely_read_attribute_for_elasticsearch
(
:assignee_ids
)
data
end
...
...
app/models/concerns/elastic/notes_search.rb
View file @
7934e400
...
...
@@ -34,7 +34,7 @@ module Elastic
if
noteable
.
is_a?
(
Issue
)
data
[
'issue'
]
=
{
assignee_id:
noteable
.
assignee_id
,
assignee_id:
noteable
.
assignee_id
s
,
author_id:
noteable
.
author_id
,
confidential:
noteable
.
confidential
}
...
...
app/models/issue_assignee.rb
View file @
7934e400
class
IssueAssignee
<
ActiveRecord
::
Base
extend
Gitlab
::
CurrentSettings
belongs_to
:issue
belongs_to
:assignee
,
class_name:
"User"
,
foreign_key: :user_id
after_create
:update_assignee_cache_counts
after_destroy
:update_assignee_cache_counts
# EE-specific
after_create
:update_elasticsearch_index
after_destroy
:update_elasticsearch_index
# EE-specific
def
update_assignee_cache_counts
assignee
&
.
update_cache_counts
end
def
update_elasticsearch_index
if
current_application_settings
.
elasticsearch_indexing?
ElasticIndexerWorker
.
perform_async
(
:update
,
'Issue'
,
issue
.
id
,
changed_fields:
[
'assignee_ids'
]
)
end
end
end
app/workers/elastic_indexer_worker.rb
View file @
7934e400
...
...
@@ -5,7 +5,7 @@ class ElasticIndexerWorker
sidekiq_options
queue: :elasticsearch
,
retry:
2
ISSUE_TRACKED_FIELDS
=
%w(assignee_id author_id confidential)
.
freeze
ISSUE_TRACKED_FIELDS
=
%w(assignee_id
s
author_id confidential)
.
freeze
def
perform
(
operation
,
class_name
,
record_id
,
options
=
{})
return
true
unless
current_application_settings
.
elasticsearch_indexing?
...
...
spec/models/concerns/elastic/issue_spec.rb
View file @
7934e400
...
...
@@ -35,7 +35,9 @@ describe Issue, elastic: true do
expected_hash
=
issue
.
attributes
.
extract!
(
'id'
,
'iid'
,
'title'
,
'description'
,
'created_at'
,
'updated_at'
,
'state'
,
'project_id'
,
'author_id'
,
'assignee_id'
,
'confidential'
)
'confidential'
)
expected_hash
[
'assignee_id'
]
=
[]
expect
(
issue
.
as_indexed_json
).
to
eq
(
expected_hash
)
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