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
a5b71685
Commit
a5b71685
authored
Aug 11, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix basic search full count load
Changelog: fixed
parent
e58a4257
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
12 deletions
+52
-12
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-0
app/views/search/show.html.haml
app/views/search/show.html.haml
+4
-1
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/lib/gitlab/search_results_spec.rb
spec/lib/gitlab/search_results_spec.rb
+4
-0
spec/views/search/show.html.haml_spec.rb
spec/views/search/show.html.haml_spec.rb
+39
-10
No files found.
app/controllers/search_controller.rb
View file @
a5b71685
...
...
@@ -39,6 +39,7 @@ class SearchController < ApplicationController
@search_service
=
Gitlab
::
View
::
Presenter
::
Factory
.
new
(
search_service
,
current_user:
current_user
).
fabricate!
@scope
=
@search_service
.
scope
@without_count
=
@search_service
.
without_count?
@show_snippets
=
@search_service
.
show_snippets?
@search_results
=
@search_service
.
search_results
@search_objects
=
@search_service
.
search_objects
...
...
app/views/search/show.html.haml
View file @
a5b71685
...
...
@@ -9,7 +9,10 @@
-
project_attributes
=
@project
&
.
attributes
&
.
slice
(
'id'
,
'namespace_id'
,
'name'
)
&
.
merge
(
name_with_namespace:
@project
&
.
name_with_namespace
)
-
if
@search_results
-
page_description
(
_
(
"%{count} %{scope} for term '%{term}'"
)
%
{
count:
@search_results
.
formatted_count
(
@scope
),
scope:
@scope
,
term:
@search_term
})
-
if
@without_count
-
page_description
(
_
(
"%{scope} results for term '%{term}'"
)
%
{
scope:
@scope
,
term:
@search_term
})
-
else
-
page_description
(
_
(
"%{count} %{scope} for term '%{term}'"
)
%
{
count:
@search_results
.
formatted_count
(
@scope
),
scope:
@scope
,
term:
@search_term
})
-
page_card_attributes
(
"Namespace"
=>
@group
&
.
full_path
,
"Project"
=>
@project
&
.
full_path
)
.page-title-holder.d-flex.flex-wrap.justify-content-between
...
...
lib/gitlab/project_search_results.rb
View file @
a5b71685
...
...
@@ -24,7 +24,7 @@ module Gitlab
when
'users'
users
.
page
(
page
).
per
(
per_page
)
else
super
(
scope
,
page:
page
,
per_page:
per_page
,
without_count:
fals
e
)
super
(
scope
,
page:
page
,
per_page:
per_page
,
without_count:
tru
e
)
end
end
...
...
locale/gitlab.pot
View file @
a5b71685
...
...
@@ -835,6 +835,9 @@ msgstr ""
msgid "%{rotation} has been recalculated with the remaining participants. Please review the new setup for %{rotation}. It is recommended that you reach out to the current on-call responder to ensure continuity of on-call coverage."
msgstr ""
msgid "%{scope} results for term '%{term}'"
msgstr ""
msgid "%{seconds}s"
msgstr ""
...
...
spec/lib/gitlab/search_results_spec.rb
View file @
a5b71685
...
...
@@ -33,6 +33,10 @@ RSpec.describe Gitlab::SearchResults do
expect
(
results
.
objects
(
'projects'
,
page:
1
,
per_page:
1
,
without_count:
false
)).
not_to
be_kind_of
(
Kaminari
::
PaginatableWithoutCount
)
end
it
'returns without counts collection when requested'
do
expect
(
results
.
objects
(
'projects'
,
page:
1
,
per_page:
1
,
without_count:
true
)).
to
be_kind_of
(
Kaminari
::
PaginatableWithoutCount
)
end
it
'uses page and per_page to paginate results'
do
project2
=
create
(
:project
,
name:
'foo'
)
...
...
spec/views/search/show.html.haml_spec.rb
View file @
a5b71685
...
...
@@ -48,21 +48,50 @@ RSpec.describe 'search/show' do
assign
(
:group
,
group
)
end
it
'renders meta tags for a group'
do
render
context
'search with full count'
do
before
do
assign
(
:without_count
,
false
)
end
it
'renders meta tags for a group'
do
render
expect
(
view
.
page_description
).
to
match
(
/\d+ issues for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
)
end
expect
(
view
.
page_description
).
to
match
(
/\d+ issues for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
)
it
'renders meta tags for both group and project'
do
project
=
build
(
:project
,
group:
group
)
assign
(
:project
,
project
)
render
expect
(
view
.
page_description
).
to
match
(
/\d+ issues for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
,
"Project"
=>
project
.
full_path
)
end
end
it
'renders meta tags for both group and project'
do
project
=
build
(
:project
,
group:
group
)
assign
(
:project
,
project
)
context
'search without full count'
do
before
do
assign
(
:without_count
,
true
)
end
it
'renders meta tags for a group'
do
render
expect
(
view
.
page_description
).
to
match
(
/issues results for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
)
end
it
'renders meta tags for both group and project'
do
project
=
build
(
:project
,
group:
group
)
assign
(
:project
,
project
)
render
render
expect
(
view
.
page_description
).
to
match
(
/\d+ issues for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
,
"Project"
=>
project
.
full_path
)
expect
(
view
.
page_description
).
to
match
(
/issues results for term '
#{
search_term
}
'/
)
expect
(
view
.
page_card_attributes
).
to
eq
(
"Namespace"
=>
group
.
full_path
,
"Project"
=>
project
.
full_path
)
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