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
ada51097
Commit
ada51097
authored
Sep 19, 2019
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add usage statistics data for monitor stage
Added usage activity data for monitor stage
parent
62052f6a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
15 deletions
+66
-15
ee/app/models/ee/clusters/cluster.rb
ee/app/models/ee/clusters/cluster.rb
+1
-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
+13
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+39
-15
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+10
-0
No files found.
ee/app/models/ee/clusters/cluster.rb
View file @
ada51097
...
...
@@ -7,6 +7,7 @@ module EE
prepended
do
prepend
HasEnvironmentScope
include
UsageStatistics
validate
:unique_environment_scope
end
...
...
ee/app/models/ee/project.rb
View file @
ada51097
...
...
@@ -119,6 +119,9 @@ module EE
scope
:with_security_reports_stored
,
->
{
where
(
'EXISTS (?)'
,
::
Vulnerabilities
::
Occurrence
.
scoped_project
.
select
(
1
))
}
scope
:with_security_reports
,
->
{
where
(
'EXISTS (?)'
,
::
Ci
::
JobArtifact
.
security_reports
.
scoped_project
.
select
(
1
))
}
scope
:with_github_service_pipeline_events
,
->
{
joins
(
:github_service
).
merge
(
GithubService
.
pipeline_hooks
)
}
scope
:with_active_prometheus_service
,
->
{
joins
(
:prometheus_service
).
merge
(
PrometheusService
.
active
)
}
scope
:with_enabled_error_tracking
,
->
{
joins
(
:error_tracking_setting
).
where
(
project_error_tracking_settings:
{
enabled:
true
})
}
scope
:with_tracing_enabled
,
->
{
joins
(
:tracing_setting
)
}
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 @
ada51097
...
...
@@ -185,6 +185,7 @@ module EE
usage_activity_by_stage:
{
create:
usage_activity_by_stage_create
,
manage:
usage_activity_by_stage_manage
,
monitor:
usage_activity_by_stage_monitor
,
plan:
usage_activity_by_stage_plan
,
verify:
usage_activity_by_stage_verify
}
...
...
@@ -216,6 +217,18 @@ module EE
}
end
def
usage_activity_by_stage_monitor
{
clusters:
::
Clusters
::
Cluster
.
distinct_count_by
(
:user_id
),
clusters_applications_prometheus:
::
Clusters
::
Applications
::
Prometheus
.
distinct_by_user
,
operations_dashboard_default_dashboard:
count
(
::
User
.
active
.
with_dashboard
(
'operations'
)),
operations_dashboard_users_with_projects_added:
count
(
UsersOpsDashboardProject
.
distinct_users
(
::
User
.
active
)),
projects_prometheus_active:
::
Project
.
with_active_prometheus_service
.
distinct_count_by
(
:creator_id
),
projects_with_error_tracking_enabled:
::
Project
.
with_enabled_error_tracking
.
distinct_count_by
(
:creator_id
),
projects_with_tracing_enabled:
::
Project
.
with_tracing_enabled
.
distinct_count_by
(
:creator_id
)
}
end
# Omitted because no user, creator or author associated: `boards`, `labels`, `milestones`, `uploads`
# Omitted because too expensive: `epics_deepest_relationship_level`
# Omitted because of encrypted properties: `projects_jira_cloud_active`, `projects_jira_server_active`
...
...
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
ada51097
...
...
@@ -39,21 +39,6 @@ describe Gitlab::UsageData 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_keys:
1
,
ldap_users:
1
)
end
end
context
'for create'
do
it
'includes accurate usage_activity_by_stage data'
do
user
=
create
(
:user
)
...
...
@@ -83,6 +68,45 @@ describe Gitlab::UsageData do
end
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_keys:
1
,
ldap_users:
1
)
end
end
context
'for monitor'
do
it
'includes accurate usage_activity_by_stage data'
do
user
=
create
(
:user
,
dashboard:
'operations'
)
cluster
=
create
(
:cluster
,
user:
user
)
project
=
create
(
:project
,
creator:
user
)
create
(
:clusters_applications_prometheus
,
:installed
,
cluster:
cluster
)
create
(
:users_ops_dashboard_project
,
user:
user
)
create
(
:prometheus_service
,
project:
project
)
create
(
:project_error_tracking_setting
,
project:
project
)
create
(
:project_tracing_setting
,
project:
project
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:monitor
]).
to
eq
(
clusters:
1
,
clusters_applications_prometheus:
1
,
operations_dashboard_default_dashboard:
1
,
operations_dashboard_users_with_projects_added:
1
,
projects_prometheus_active:
1
,
projects_with_error_tracking_enabled:
1
,
projects_with_tracing_enabled:
1
)
end
end
context
'for plan'
do
it
'includes accurate usage_activity_by_stage data'
do
stub_licensed_features
(
board_assignee_lists:
true
,
board_milestone_lists:
true
)
...
...
ee/spec/models/project_spec.rb
View file @
ada51097
...
...
@@ -152,6 +152,16 @@ describe Project do
expect
(
described_class
.
with_github_service_pipeline_events
).
not_to
include
(
project_without_github_service_pipeline_events
)
end
end
describe
'.with_active_prometheus_service'
do
it
'returns the correct project'
do
project_with_active_prometheus_service
=
create
(
:prometheus_project
)
project_without_active_prometheus_service
=
create
(
:project
)
expect
(
described_class
.
with_active_prometheus_service
).
to
include
(
project_with_active_prometheus_service
)
expect
(
described_class
.
with_active_prometheus_service
).
not_to
include
(
project_without_active_prometheus_service
)
end
end
end
describe
'validations'
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