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
860d2c73
Commit
860d2c73
authored
Mar 15, 2020
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove second sql query for already loaded project
parent
fb4e6965
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
ee/app/services/ee/search/project_service.rb
ee/app/services/ee/search/project_service.rb
+1
-1
ee/lib/gitlab/elastic/project_search_results.rb
ee/lib/gitlab/elastic/project_search_results.rb
+2
-2
ee/spec/lib/gitlab/elastic/project_search_results_spec.rb
ee/spec/lib/gitlab/elastic/project_search_results_spec.rb
+14
-14
No files found.
ee/app/services/ee/search/project_service.rb
View file @
860d2c73
...
...
@@ -13,7 +13,7 @@ module EE
::
Gitlab
::
Elastic
::
ProjectSearchResults
.
new
(
current_user
,
params
[
:search
],
project
.
id
,
project
,
repository_ref
)
end
...
...
ee/lib/gitlab/elastic/project_search_results.rb
View file @
860d2c73
...
...
@@ -11,9 +11,9 @@ module Gitlab
delegate
:users
,
to: :generic_search_results
delegate
:limited_users_count
,
to: :generic_search_results
def
initialize
(
current_user
,
query
,
project
_id
,
repository_ref
=
nil
)
def
initialize
(
current_user
,
query
,
project
,
repository_ref
=
nil
)
@current_user
=
current_user
@project
=
Project
.
find
(
project_id
)
@project
=
project
@repository_ref
=
repository_ref
.
presence
||
project
.
default_branch
@query
=
query
@public_and_internal_projects
=
false
...
...
ee/spec/lib/gitlab/elastic/project_search_results_spec.rb
View file @
860d2c73
...
...
@@ -12,7 +12,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
describe
'initialize with empty ref'
do
subject
(
:results
)
{
described_class
.
new
(
user
,
query
,
project
.
id
,
''
)
}
subject
(
:results
)
{
described_class
.
new
(
user
,
query
,
project
,
''
)
}
it
{
expect
(
results
.
project
).
to
eq
(
project
)
}
it
{
expect
(
results
.
repository_ref
).
to
eq
(
'master'
)
}
...
...
@@ -22,7 +22,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
describe
'initialize with ref'
do
let
(
:ref
)
{
'refs/heads/test'
}
subject
(
:results
)
{
described_class
.
new
(
user
,
query
,
project
.
id
,
ref
)
}
subject
(
:results
)
{
described_class
.
new
(
user
,
query
,
project
,
ref
)
}
it
{
expect
(
results
.
project
).
to
eq
(
project
)
}
it
{
expect
(
results
.
repository_ref
).
to
eq
(
ref
)
}
...
...
@@ -49,12 +49,12 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
ensure_elasticsearch_index!
result
=
described_class
.
new
(
user
,
'term'
,
project
.
id
)
result
=
described_class
.
new
(
user
,
'term'
,
project
)
expect
(
result
.
notes_count
).
to
eq
(
1
)
expect
(
result
.
wiki_blobs_count
).
to
eq
(
1
)
expect
(
result
.
blobs_count
).
to
eq
(
1
)
result1
=
described_class
.
new
(
user
,
'initial'
,
project
.
id
)
result1
=
described_class
.
new
(
user
,
'initial'
,
project
)
expect
(
result1
.
commits_count
).
to
eq
(
1
)
end
...
...
@@ -70,7 +70,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
ensure_elasticsearch_index!
result
=
described_class
.
new
(
guest
,
'term'
,
project
.
id
)
result
=
described_class
.
new
(
guest
,
'term'
,
project
)
expect
(
result
.
wiki_blobs_count
).
to
eq
(
1
)
end
end
...
...
@@ -79,7 +79,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
describe
"search for commits in non-default branch"
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
visibility
)
}
let
(
:visibility
)
{
:repository_enabled
}
let
(
:result
)
{
described_class
.
new
(
user
,
'initial'
,
project
.
id
,
'test'
)
}
let
(
:result
)
{
described_class
.
new
(
user
,
'initial'
,
project
,
'test'
)
}
subject
(
:commits
)
{
result
.
objects
(
'commits'
)
}
...
...
@@ -122,7 +122,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
describe
'search for blobs in non-default branch'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
:repository_private
)
}
let
(
:result
)
{
described_class
.
new
(
user
,
'initial'
,
project
.
id
,
'test'
)
}
let
(
:result
)
{
described_class
.
new
(
user
,
'initial'
,
project
,
'test'
)
}
subject
(
:blobs
)
{
result
.
objects
(
'blobs'
)
}
...
...
@@ -149,7 +149,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
it
'does not list project confidential issues for non project members'
do
results
=
described_class
.
new
(
non_member
,
query
,
project
.
id
)
results
=
described_class
.
new
(
non_member
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -159,7 +159,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
it
'lists project confidential issues for author'
do
results
=
described_class
.
new
(
author
,
query
,
project
.
id
)
results
=
described_class
.
new
(
author
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -169,7 +169,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
it
'lists project confidential issues for assignee'
do
results
=
described_class
.
new
(
assignee
,
query
,
project
.
id
)
results
=
described_class
.
new
(
assignee
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -181,7 +181,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
it
'lists project confidential issues for project members'
do
project
.
add_developer
(
member
)
results
=
described_class
.
new
(
member
,
query
,
project
.
id
)
results
=
described_class
.
new
(
member
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -193,7 +193,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
it
'does not list project confidential issues for project members with guest role'
do
project
.
add_guest
(
member
)
results
=
described_class
.
new
(
member
,
query
,
project
.
id
)
results
=
described_class
.
new
(
member
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -203,7 +203,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
it
'lists all project issues for admin'
do
results
=
described_class
.
new
(
admin
,
query
,
project
.
id
)
results
=
described_class
.
new
(
admin
,
query
,
project
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue
...
...
@@ -214,7 +214,7 @@ describe Gitlab::Elastic::ProjectSearchResults, :elastic do
end
context
'user search'
do
subject
(
:results
)
{
described_class
.
new
(
user
,
project
.
owner
.
username
,
project
.
id
)
}
subject
(
:results
)
{
described_class
.
new
(
user
,
project
.
owner
.
username
,
project
)
}
before
do
expect
(
Gitlab
::
ProjectSearchResults
).
to
receive
(
:new
).
and_call_original
...
...
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