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
661c1cff
Commit
661c1cff
authored
Feb 04, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EE] Reduce diff with CE in Search::GlobalService
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
9ed0575a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
26 deletions
+56
-26
app/services/search/global_service.rb
app/services/search/global_service.rb
+12
-26
ee/app/services/ee/search/global_service.rb
ee/app/services/ee/search/global_service.rb
+44
-0
No files found.
app/services/search/global_service.rb
View file @
661c1cff
...
...
@@ -2,6 +2,8 @@
module
Search
class
GlobalService
include
Gitlab
::
Utils
::
StrongMemoize
attr_accessor
:current_user
,
:params
attr_reader
:default_project_filter
...
...
@@ -11,42 +13,26 @@ module Search
end
def
execute
if
Gitlab
::
CurrentSettings
.
elasticsearch_search?
Gitlab
::
Elastic
::
SearchResults
.
new
(
current_user
,
params
[
:search
],
elastic_projects
,
elastic_global
)
else
Gitlab
::
SearchResults
.
new
(
current_user
,
projects
,
params
[
:search
],
default_project_filter:
default_project_filter
)
end
Gitlab
::
SearchResults
.
new
(
current_user
,
projects
,
params
[
:search
],
default_project_filter:
default_project_filter
)
end
def
projects
@projects
||=
ProjectsFinder
.
new
(
current_user:
current_user
).
execute
end
# rubocop: disable CodeReuse/ActiveRecord
def
elastic_projects
@elastic_projects
||=
if
current_user
&
.
full_private_access?
:any
elsif
current_user
current_user
.
authorized_projects
.
pluck
(
:id
)
else
[]
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
elastic_global
true
def
allowed_scopes
strong_memoize
(
:allowed_scopes
)
do
%w[issues merge_requests milestones]
end
end
def
scope
@scope
||=
begin
allowed_scopes
=
%w[issues merge_requests milestones]
allowed_scopes
+=
%w[wiki_blobs blobs commits]
if
Gitlab
::
CurrentSettings
.
elasticsearch_search?
allowed_scopes
.
delete
(
params
[
:scope
])
{
'projects'
}
strong_memoize
(
:scope
)
do
allowed_scopes
.
include?
(
params
[
:scope
])
?
params
[
:scope
]
:
'projects'
end
end
end
end
Search
::
GlobalService
.
prepend
(
EE
::
Search
::
GlobalService
)
ee/app/services/ee/search/global_service.rb
0 → 100644
View file @
661c1cff
# frozen_string_literal: true
module
EE
module
Search
module
GlobalService
extend
::
Gitlab
::
Utils
::
Override
include
::
Gitlab
::
Utils
::
StrongMemoize
override
:execute
def
execute
if
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
::
Gitlab
::
Elastic
::
SearchResults
.
new
(
current_user
,
params
[
:search
],
elastic_projects
,
elastic_global
)
else
super
end
end
def
elastic_projects
strong_memoize
(
:elastic_projects
)
do
if
current_user
&
.
full_private_access?
:any
elsif
current_user
current_user
.
authorized_projects
.
pluck
(
:id
)
# rubocop: disable CodeReuse/ActiveRecord
else
[]
end
end
end
def
elastic_global
true
end
override
:allowed_scopes
def
allowed_scopes
strong_memoize
(
:ee_allowed_scopes
)
do
super
.
tap
do
|
ce_scopes
|
ce_scopes
.
concat
(
%w[wiki_blobs blobs commits]
)
if
::
Gitlab
::
CurrentSettings
.
elasticsearch_search?
end
end
end
end
end
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