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
eabd6b51
Commit
eabd6b51
authored
Jul 29, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
3b3f0e94
2e496492
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
7 deletions
+70
-7
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+8
-0
app/views/layouts/_search.html.haml
app/views/layouts/_search.html.haml
+1
-0
changelogs/unreleased/fj-navbar-searches-usage-ping-counter.yml
...logs/unreleased/fj-navbar-searches-usage-ping-counter.yml
+5
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+5
-2
lib/gitlab/usage_data_counters/search_counter.rb
lib/gitlab/usage_data_counters/search_counter.rb
+27
-0
spec/features/global_search_spec.rb
spec/features/global_search_spec.rb
+9
-4
spec/lib/gitlab/usage_data_counters/search_counter_spec.rb
spec/lib/gitlab/usage_data_counters/search_counter_spec.rb
+13
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+2
-1
No files found.
app/controllers/search_controller.rb
View file @
eabd6b51
...
...
@@ -31,6 +31,8 @@ class SearchController < ApplicationController
render_commits
if
@scope
==
'commits'
eager_load_user_status
if
@scope
==
'users'
increment_navbar_searches_counter
check_single_commit_result
end
...
...
@@ -70,4 +72,10 @@ class SearchController < ApplicationController
redirect_to
project_commit_path
(
@project
,
only_commit
)
if
found_by_commit_sha
end
end
def
increment_navbar_searches_counter
return
if
params
[
:nav_source
]
!=
'navbar'
Gitlab
::
UsageDataCounters
::
SearchCounter
.
increment_navbar_searches_count
end
end
app/views/layouts/_search.html.haml
View file @
eabd6b51
...
...
@@ -45,5 +45,6 @@
-
if
@snippet
||
@snippets
=
hidden_field_tag
:snippets
,
true
=
hidden_field_tag
:repository_ref
,
@ref
=
hidden_field_tag
:nav_source
,
'navbar'
=
button_tag
'Go'
if
ENV
[
'RAILS_ENV'
]
==
'test'
.search-autocomplete-opts.hide
{
:'data-autocomplete-path'
=>
search_autocomplete_path
,
:'data-autocomplete-project-id'
=>
@project
.
try
(
:id
),
:'data-autocomplete-project-ref'
=>
@ref
}
changelogs/unreleased/fj-navbar-searches-usage-ping-counter.yml
0 → 100644
View file @
eabd6b51
---
title
:
Added navbar searches usage ping counter
merge_request
:
30953
author
:
type
:
changed
lib/gitlab/usage_data.rb
View file @
eabd6b51
...
...
@@ -137,8 +137,11 @@ module Gitlab
# @return [Array<#totals>] An array of objects that respond to `#totals`
def
usage_data_counters
[
Gitlab
::
UsageDataCounters
::
WikiPageCounter
,
Gitlab
::
UsageDataCounters
::
WebIdeCounter
]
[
Gitlab
::
UsageDataCounters
::
WikiPageCounter
,
Gitlab
::
UsageDataCounters
::
WebIdeCounter
,
Gitlab
::
UsageDataCounters
::
SearchCounter
]
end
def
components_usage_data
...
...
lib/gitlab/usage_data_counters/search_counter.rb
0 → 100644
View file @
eabd6b51
# frozen_string_literal: true
module
Gitlab
module
UsageDataCounters
class
SearchCounter
extend
RedisCounter
NAVBAR_SEARCHES_COUNT_KEY
=
'NAVBAR_SEARCHES_COUNT'
class
<<
self
def
increment_navbar_searches_count
increment
(
NAVBAR_SEARCHES_COUNT_KEY
)
end
def
total_navbar_searches_count
total_count
(
NAVBAR_SEARCHES_COUNT_KEY
)
end
def
totals
{
navbar_searches:
total_navbar_searches_count
}
end
end
end
end
end
spec/features/global_search_spec.rb
View file @
eabd6b51
...
...
@@ -9,6 +9,15 @@ describe 'Global search' do
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
visit
dashboard_projects_path
end
it
'increases usage ping searches counter'
do
expect
(
Gitlab
::
UsageDataCounters
::
SearchCounter
).
to
receive
(
:increment_navbar_searches_count
)
fill_in
"search"
,
with:
"foobar"
click_button
"Go"
end
describe
'I search through the issues and I see pagination'
do
...
...
@@ -18,8 +27,6 @@ describe 'Global search' do
end
it
"has a pagination"
do
visit
dashboard_projects_path
fill_in
"search"
,
with:
"initial"
click_button
"Go"
...
...
@@ -29,8 +36,6 @@ describe 'Global search' do
end
it
'closes the dropdown on blur'
,
:js
do
visit
dashboard_projects_path
fill_in
'search'
,
with:
"a"
dropdown
=
find
(
'.js-dashboard-search-options'
)
...
...
spec/lib/gitlab/usage_data_counters/search_counter_spec.rb
0 → 100644
View file @
eabd6b51
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
SearchCounter
,
:clean_gitlab_redis_shared_state
do
it
'increments counter and return the total count'
do
expect
(
described_class
.
total_navbar_searches_count
).
to
eq
(
0
)
2
.
times
{
described_class
.
increment_navbar_searches_count
}
expect
(
described_class
.
total_navbar_searches_count
).
to
eq
(
2
)
end
end
spec/lib/gitlab/usage_data_spec.rb
View file @
eabd6b51
...
...
@@ -67,7 +67,8 @@ describe Gitlab::UsageData do
wiki_pages_delete:
a_kind_of
(
Integer
),
web_ide_views:
a_kind_of
(
Integer
),
web_ide_commits:
a_kind_of
(
Integer
),
web_ide_merge_requests:
a_kind_of
(
Integer
)
web_ide_merge_requests:
a_kind_of
(
Integer
),
navbar_searches:
a_kind_of
(
Integer
)
)
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