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
95263a0e
Commit
95263a0e
authored
Jul 16, 2019
by
Ash McKenzie
Committed by
Alex Buijs
Aug 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New usage_activity_by_stage for UsageData
Focusing on Manage
parent
3ff1f8a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+23
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+34
-0
No files found.
ee/lib/ee/gitlab/usage_data.rb
View file @
95263a0e
...
...
@@ -13,6 +13,13 @@ module EE
super
+
[
::
Gitlab
::
UsageCounters
::
DesignsCounter
]
end
override
:uncached_data
def
uncached_data
return
super
unless
::
Feature
.
enabled?
(
:usage_activity_by_stage
,
default_enabled:
true
)
super
.
merge
(
usage_activity_by_stage
)
end
override
:features_usage_data
def
features_usage_data
super
.
merge
(
features_usage_data_ee
)
...
...
@@ -165,6 +172,22 @@ module EE
count
(
::
Issue
.
authored
(
::
User
.
alert_bot
))
end
# Source: https://gitlab.com/gitlab-data/analytics/blob/master/transform/snowflake-dbt/data/ping_metrics_to_stage_mapping_data.csv
# rubocop: disable CodeReuse/ActiveRecord
def
usage_activity_by_stage
{
usage_activity_by_stage:
{
manage:
{
groups:
count
(
::
GroupMember
.
distinct
,
count_by: :user_id
),
ldap_group_links:
-
1
,
# no creator / user ID
ldap_keys:
count
(
::
LDAPKey
.
distinct
,
count_by: :user_id
),
ldap_users:
count
(
::
GroupMember
.
distinct
.
of_ldap_type
,
count_by: :user_id
)
}
}
}
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
...
...
ee/spec/lib/ee/gitlab/usage_data_spec.rb
0 → 100644
View file @
95263a0e
require
'spec_helper'
describe
Gitlab
::
UsageData
do
describe
'.uncached_data'
do
context
'when the :usage_activity_by_stage feaure is not enabled'
do
it
'does not include usage_activity_by_stage data'
do
stub_feature_flags
(
usage_activity_by_stage:
false
)
expect
(
described_class
.
uncached_data
).
not_to
include
(
:usage_activity_by_stage
)
end
end
context
'when the :usage_activity_by_stage feaure is enabled'
do
before
do
stub_feature_flags
(
usage_activity_by_stage:
true
)
end
it
'includes usage_activity_by_stage data'
do
expect
(
described_class
.
uncached_data
).
to
include
(
:usage_activity_by_stage
)
end
context
'for manage'
do
it
'includes accurate usage_activity_by_stage data'
do
user
=
create
(
:user
)
create
(
:group_member
,
user:
user
)
create
(
:key
,
type:
'LDAPKey'
,
user:
user
)
create
(
:group_member
,
ldap:
true
,
user:
user
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:manage
]).
to
eq
(
groups:
1
,
ldap_group_links:
-
1
,
ldap_keys:
1
,
ldap_users:
1
)
end
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