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
e864e92a
Commit
e864e92a
authored
Sep 20, 2019
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add usage statistics data for configure stage
Added usage activity data for the configure stage
parent
77ce59ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
0 deletions
+77
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+3
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+23
-0
ee/spec/factories/services.rb
ee/spec/factories/services.rb
+13
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+38
-0
No files found.
ee/app/models/ee/project.rb
View file @
e864e92a
...
...
@@ -127,6 +127,9 @@ module EE
joins
(
:project_feature
).
mirror
.
where
(
mirror_trigger_builds:
true
,
project_features:
{
builds_access_level:
::
ProjectFeature
::
ENABLED
})
end
scope
:with_slack_service
,
->
{
joins
(
:slack_service
)
}
scope
:with_slack_slash_commands_service
,
->
{
joins
(
:slack_slash_commands_service
)
}
scope
:with_prometheus_service
,
->
{
joins
(
:prometheus_service
)
}
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
to: :statistics
,
allow_nil:
true
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
e864e92a
...
...
@@ -169,6 +169,7 @@ module EE
def
usage_activity_by_stage
{
usage_activity_by_stage:
{
configure:
usage_activity_by_stage_configure
,
create:
usage_activity_by_stage_create
,
manage:
usage_activity_by_stage_manage
,
monitor:
usage_activity_by_stage_monitor
,
...
...
@@ -180,6 +181,28 @@ module EE
}
end
# Omitted because no user, creator or author associated: `auto_devops_disabled`, `auto_devops_enabled`
# Omitted because not in use anymore: `gcp_clusters`, `gcp_clusters_disabled`, `gcp_clusters_enabled`
def
usage_activity_by_stage_configure
{
clusters_applications_cert_managers:
::
Clusters
::
Applications
::
CertManager
.
distinct_by_user
,
clusters_applications_helm:
::
Clusters
::
Applications
::
Helm
.
distinct_by_user
,
clusters_applications_ingress:
::
Clusters
::
Applications
::
Ingress
.
distinct_by_user
,
clusters_applications_knative:
::
Clusters
::
Applications
::
Knative
.
distinct_by_user
,
clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
distinct_count_by
(
:user_id
),
clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
distinct_count_by
(
:user_id
),
clusters_platforms_gke:
::
Clusters
::
Cluster
.
gcp_installed
.
enabled
.
distinct_count_by
(
:user_id
),
clusters_platforms_user:
::
Clusters
::
Cluster
.
user_provided
.
enabled
.
distinct_count_by
(
:user_id
),
group_clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
group_type
.
distinct_count_by
(
:user_id
),
group_clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
group_type
.
distinct_count_by
(
:user_id
),
project_clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
project_type
.
distinct_count_by
(
:user_id
),
project_clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
project_type
.
distinct_count_by
(
:user_id
),
projects_slack_notifications_active:
::
Project
.
with_slack_service
.
distinct_count_by
(
:creator_id
),
projects_slack_slash_active:
::
Project
.
with_slack_slash_commands_service
.
distinct_count_by
(
:creator_id
),
projects_with_prometheus_alerts:
::
Project
.
with_prometheus_service
.
distinct_count_by
(
:creator_id
)
}
end
# Omitted because no user, creator or author associated: `lfs_objects`, `pool_repositories`, `web_hooks`
def
usage_activity_by_stage_create
{
...
...
ee/spec/factories/services.rb
View file @
e864e92a
...
...
@@ -23,4 +23,17 @@ FactoryBot.define do
token
{
'github-token'
}
type
{
'GithubService'
}
end
factory
:slack_service
do
project
active
{
true
}
webhook
{
'https://slack.service.url'
}
type
{
'SlackService'
}
end
factory
:slack_slash_commands_service
do
project
active
{
true
}
type
{
'SlackSlashCommandsService'
}
end
end
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
e864e92a
...
...
@@ -39,6 +39,44 @@ describe Gitlab::UsageData do
expect
(
described_class
.
uncached_data
).
to
include
(
:usage_activity_by_stage
)
end
context
'for configure'
do
it
'includes accurate usage_activity_by_stage data'
do
user
=
create
(
:user
)
cluster
=
create
(
:cluster
,
user:
user
)
project
=
create
(
:project
,
creator:
user
)
create
(
:clusters_applications_cert_manager
,
:installed
,
cluster:
cluster
)
create
(
:clusters_applications_helm
,
:installed
,
cluster:
cluster
)
create
(
:clusters_applications_ingress
,
:installed
,
cluster:
cluster
)
create
(
:clusters_applications_knative
,
:installed
,
cluster:
cluster
)
create
(
:cluster
,
:disabled
,
user:
user
)
create
(
:cluster
,
:provided_by_gcp
,
user:
user
)
create
(
:cluster
,
:provided_by_user
,
user:
user
)
create
(
:cluster
,
:group
,
:disabled
,
user:
user
)
create
(
:cluster
,
:group
,
user:
user
)
create
(
:slack_service
,
project:
project
)
create
(
:slack_slash_commands_service
,
project:
project
)
create
(
:prometheus_service
,
project:
project
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:configure
]).
to
eq
(
clusters_applications_cert_managers:
1
,
clusters_applications_helm:
1
,
clusters_applications_ingress:
1
,
clusters_applications_knative:
1
,
clusters_disabled:
1
,
clusters_enabled:
4
,
clusters_platforms_gke:
1
,
clusters_platforms_user:
1
,
group_clusters_disabled:
1
,
group_clusters_enabled:
1
,
project_clusters_disabled:
1
,
project_clusters_enabled:
4
,
projects_slack_notifications_active:
1
,
projects_slack_slash_active:
1
,
projects_with_prometheus_alerts:
1
)
end
end
context
'for create'
do
it
'includes accurate usage_activity_by_stage data'
do
user
=
create
(
:user
)
...
...
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