Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PortalMEC
portalmec
Commits
9b9742e1
Commit
9b9742e1
authored
8 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
Add total results of search in header
parent
98277327
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!312
Total count in search
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/v1/search_controller.rb
+3
-1
3 additions, 1 deletion
app/controllers/v1/search_controller.rb
app/services/search_service.rb
+1
-1
1 addition, 1 deletion
app/services/search_service.rb
test/services/search_service_test.rb
+3
-3
3 additions, 3 deletions
test/services/search_service_test.rb
with
7 additions
and
5 deletions
app/controllers/v1/search_controller.rb
+
3
−
1
View file @
9b9742e1
...
...
@@ -4,7 +4,9 @@ class V1::SearchController < ApplicationController
# GET v1/search
# GET v1/search.json
def
index
render
json:
SearchService
.
search
(
@search
,
current_user
),
status: :ok
search
=
SearchService
.
search
(
@search
,
current_user
)
headers
[
'X-Total-Count'
]
=
search
.
total_count
render
json:
search
.
results
,
status: :ok
rescue
SearchService
::
InvalidSearchError
render
json:
@search
.
errors
,
status: :bad_request
end
...
...
This diff is collapsed.
Click to expand it.
app/services/search_service.rb
+
1
−
1
View file @
9b9742e1
...
...
@@ -5,7 +5,7 @@ module SearchService
def
self
.
search
(
search
,
user
)
model
=
instance
(
search
,
user
)
model
.
search
.
results
model
.
search
end
def
self
.
autocomplete
(
search
,
user
)
...
...
This diff is collapsed.
Click to expand it.
test/services/search_service_test.rb
+
3
−
3
View file @
9b9742e1
...
...
@@ -4,21 +4,21 @@ class SearchServiceTest < ActiveSupport::TestCase
test
'fetch learning object with all search params'
do
reindex
LearningObject
search
=
SearchService
.
search
(
Search
.
new
(
los_complete_search
),
users
(
:john
))
search
=
SearchService
.
search
(
Search
.
new
(
los_complete_search
),
users
(
:john
))
.
results
search
.
each
{
|
o
|
assert_instance_of
LearningObject
,
o
}
end
test
'fetch all public collections'
do
reindex
Collection
search
=
SearchService
.
search
(
Search
.
new
(
collections_search
),
users
(
:john
))
search
=
SearchService
.
search
(
Search
.
new
(
collections_search
),
users
(
:john
))
.
results
search
.
each
{
|
o
|
assert_instance_of
Collection
,
o
}
end
test
'fetch users named john'
do
reindex
User
search
=
SearchService
.
search
(
Search
.
new
(
users_john_search
),
users
(
:john
))
search
=
SearchService
.
search
(
Search
.
new
(
users_john_search
),
users
(
:john
))
.
results
assert_equal
[
users
(
:john
),
users
(
:one
)],
search
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment