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
950f9881
Commit
950f9881
authored
Sep 02, 2020
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix i_search_paid metric
parent
d8e6347d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
22 deletions
+60
-22
ee/app/controllers/ee/search_controller.rb
ee/app/controllers/ee/search_controller.rb
+5
-4
ee/spec/controllers/ee/search_controller_spec.rb
ee/spec/controllers/ee/search_controller_spec.rb
+46
-15
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+9
-3
No files found.
ee/app/controllers/ee/search_controller.rb
View file @
950f9881
...
@@ -12,11 +12,12 @@ module EE
...
@@ -12,11 +12,12 @@ module EE
def
track_advanced_search
def
track_advanced_search
# track unique users of advanced global search
# track unique users of advanced global search
track_unique_redis_hll_event
(
"i_search_advanced"
,
:search_track_unique_users
)
if
search_service
.
use_elasticsearch?
track_unique_redis_hll_event
(
'i_search_advanced'
,
:search_track_unique_users
)
if
search_service
.
use_elasticsearch?
# track unique users who search against paid groups/projects
# track unique paid users (users who already use elasticsearch and users who could use it if they enable elasticsearch integration)
# this line is commented out because of https://gitlab.com/gitlab-org/gitlab/-/issues/243486
# for gitlab.com we check if the search uses elasticsearch
# track_unique_redis_hll_event("i_search_paid", :search_track_unique_users) if (search_service.project || search_service.group)&.feature_available?(:elastic_search)
# for self-managed we check if the licensed feature available
track_unique_redis_hll_event
(
'i_search_paid'
,
:search_track_unique_users
)
if
(
::
Gitlab
.
com?
&&
search_service
.
use_elasticsearch?
)
||
(
!::
Gitlab
.
com?
&&
License
.
feature_available?
(
:elastic_search
))
end
end
end
end
end
end
ee/spec/controllers/ee/search_controller_spec.rb
View file @
950f9881
...
@@ -30,25 +30,56 @@ RSpec.describe SearchController do
...
@@ -30,25 +30,56 @@ RSpec.describe SearchController do
end
end
end
end
# i_search_paid is commented out because of https://gitlab.com/gitlab-org/gitlab/-/issues/243486
context
'i_search_paid'
do
# context 'i_search_paid' do
let_it_be
(
:group
)
{
create
(
:group
)
}
# let(:group) { create(:group) }
# let(:request_params) { { group_id: group.id, scope: 'blobs', search: 'term' } }
# let(:target_id) { 'i_search_paid' }
# before do
let
(
:request_params
)
{
{
group_id:
group
.
id
,
scope:
'blobs'
,
search:
'term'
}
}
# allow(group).to receive(:feature_available?).with(:elastic_search).and_return(true)
let
(
:target_id
)
{
'i_search_paid'
}
# end
# it_behaves_like 'tracking unique hll events', :show
context
'on Gitlab.com'
do
before
do
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
end
# it 'does not track if feature flag is disabled' do
it_behaves_like
'tracking unique hll events'
,
:show
# stub_feature_flags(search_track_unique_users: false)
# expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(instance_of(String), target_id)
# get :show, params: request_params, format: :html
it
'does not track if feature flag is disabled'
do
# end
stub_feature_flags
(
search_track_unique_users:
false
)
# end
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
not_to
receive
(
:track_event
).
with
(
instance_of
(
String
),
target_id
)
get
:show
,
params:
request_params
,
format: :html
end
end
context
'self-managed instance'
do
before
do
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
)
end
context
'license is available'
do
before
do
stub_licensed_features
(
elastic_search:
true
)
end
it_behaves_like
'tracking unique hll events'
,
:show
it
'does not track if feature flag is disabled'
do
stub_feature_flags
(
search_track_unique_users:
false
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
not_to
receive
(
:track_event
).
with
(
instance_of
(
String
),
target_id
)
get
:show
,
params:
request_params
,
format: :html
end
end
it
'does not track if there is no license available'
do
stub_licensed_features
(
elastic_search:
false
)
expect
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
not_to
receive
(
:track_event
).
with
(
instance_of
(
String
),
target_id
)
get
:show
,
params:
request_params
,
format: :html
end
end
end
end
end
end
end
end
end
spec/controllers/search_controller_spec.rb
View file @
950f9881
...
@@ -149,9 +149,15 @@ RSpec.describe SearchController do
...
@@ -149,9 +149,15 @@ RSpec.describe SearchController do
expect
(
assigns
[
:search_objects
].
first
).
to
eq
note
expect
(
assigns
[
:search_objects
].
first
).
to
eq
note
end
end
it_behaves_like
'tracking unique hll events'
,
:show
do
context
'unique users tracking'
do
let
(
:request_params
)
{
{
scope:
'projects'
,
search:
'term'
}
}
before
do
let
(
:target_id
)
{
'i_search_total'
}
allow
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
).
to
receive
(
:track_event
)
end
it_behaves_like
'tracking unique hll events'
,
:show
do
let
(
:request_params
)
{
{
scope:
'projects'
,
search:
'term'
}
}
let
(
:target_id
)
{
'i_search_total'
}
end
end
end
context
'on restricted projects'
do
context
'on restricted projects'
do
...
...
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