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
2c31cb59
Commit
2c31cb59
authored
Aug 06, 2020
by
Dmitry Gruzd
Committed by
Dylan Griffith
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve confidentiality search check for AGS, scope: issues
parent
cf683ab9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
ee/changelogs/unreleased/228818-optimize-es-projects-filtering.yml
...logs/unreleased/228818-optimize-es-projects-filtering.yml
+5
-0
ee/lib/elastic/latest/issue_class_proxy.rb
ee/lib/elastic/latest/issue_class_proxy.rb
+14
-4
No files found.
ee/changelogs/unreleased/228818-optimize-es-projects-filtering.yml
0 → 100644
View file @
2c31cb59
---
title
:
Improve issues confidentiality check performance for AGS
merge_request
:
38564
author
:
type
:
performance
ee/lib/elastic/latest/issue_class_proxy.rb
View file @
2c31cb59
...
...
@@ -13,15 +13,25 @@ module Elastic
options
[
:features
]
=
'issues'
query_hash
=
project_ids_filter
(
query_hash
,
options
)
query_hash
=
confidentiality_filter
(
query_hash
,
options
[
:current_user
])
query_hash
=
confidentiality_filter
(
query_hash
,
options
[
:current_user
]
,
options
[
:project_ids
]
)
search
(
query_hash
,
options
)
end
private
def
confidentiality_filter
(
query_hash
,
current_user
)
return
query_hash
if
current_user
&&
current_user
.
can_read_all_resources?
def
user_has_access_to_confidential_issues?
(
authorized_project_ids
,
project_ids
)
# is_a?(Array) is needed because we might receive project_ids: :any
return
false
unless
authorized_project_ids
&&
project_ids
.
is_a?
(
Array
)
(
project_ids
-
authorized_project_ids
).
empty?
end
def
confidentiality_filter
(
query_hash
,
current_user
,
project_ids
)
return
query_hash
if
current_user
&
.
can_read_all_resources?
authorized_project_ids
=
current_user
&
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
)
&
.
pluck_primary_key
return
query_hash
if
user_has_access_to_confidential_issues?
(
authorized_project_ids
,
project_ids
)
filter
=
if
current_user
...
...
@@ -38,7 +48,7 @@ module Elastic
should:
[
{
term:
{
author_id:
current_user
.
id
}
},
{
term:
{
assignee_id:
current_user
.
id
}
},
{
terms:
{
project_id:
current_user
.
authorized_projects
(
Gitlab
::
Access
::
REPORTER
).
pluck_primary_key
}
}
{
terms:
{
project_id:
authorized_project_ids
}
}
]
}
}
...
...
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