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
560de38b
Commit
560de38b
authored
Aug 21, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move package usage data to core
Move package data to core as prep work for adding extra metrics.
parent
d441a318
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
30 deletions
+32
-30
changelogs/unreleased/205578-move-package-metrics-to-core.yml
...gelogs/unreleased/205578-move-package-metrics-to-core.yml
+5
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+0
-8
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+0
-21
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+6
-1
spec/factories/usage_data.rb
spec/factories/usage_data.rb
+4
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+17
-0
No files found.
changelogs/unreleased/205578-move-package-metrics-to-core.yml
0 → 100644
View file @
560de38b
---
title
:
Move package usage ping data to core
merge_request
:
40032
author
:
type
:
changed
ee/lib/ee/gitlab/usage_data.rb
View file @
560de38b
...
...
@@ -174,7 +174,6 @@ module EE
merge_requests_with_required_codeowners:
distinct_count
(
::
ApprovalMergeRequestRule
.
code_owner_approval_required
,
:merge_request_id
),
projects_mirrored_with_pipelines_enabled:
count
(
::
Project
.
mirrored_with_enabled_pipelines
),
projects_reporting_ci_cd_back_to_github:
count
(
::
GithubService
.
active
),
projects_with_packages:
distinct_count
(
::
Packages
::
Package
,
:project_id
),
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
),
status_page_projects:
count
(
::
StatusPage
::
ProjectSetting
.
enabled
),
status_page_issues:
count
(
::
Issue
.
on_status_page
,
start:
issue_minimum_id
,
finish:
issue_maximum_id
),
...
...
@@ -266,13 +265,6 @@ module EE
})
end
override
:usage_activity_by_stage_package
def
usage_activity_by_stage_package
(
time_period
)
super
.
merge
({
projects_with_packages:
distinct_count
(
::
Project
.
with_packages
.
where
(
time_period
),
: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 @
560de38b
...
...
@@ -36,10 +36,6 @@ RSpec.describe Gitlab::UsageData do
create
(
:service
,
project:
projects
[
1
],
type:
'JenkinsService'
,
active:
true
)
create
(
:jira_service
,
project:
projects
[
0
],
issues_enabled:
true
,
project_key:
'GL'
)
create
(
:package
,
project:
projects
[
0
])
create
(
:package
,
project:
projects
[
0
])
create
(
:package
,
project:
projects
[
1
])
create
(
:project_tracing_setting
,
project:
projects
[
0
])
create
(
:operations_feature_flag
,
project:
projects
[
0
])
...
...
@@ -111,7 +107,6 @@ RSpec.describe Gitlab::UsageData do
projects_jira_issuelist_active
projects_mirrored_with_pipelines_enabled
projects_reporting_ci_cd_back_to_github
projects_with_packages
projects_with_prometheus_alerts
projects_with_tracing_enabled
sast_jobs
...
...
@@ -129,7 +124,6 @@ RSpec.describe Gitlab::UsageData do
expect
(
count_data
[
:projects_jenkins_active
]).
to
eq
(
1
)
expect
(
count_data
[
:projects_with_prometheus_alerts
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_with_packages
]).
to
eq
(
2
)
expect
(
count_data
[
:feature_flags
]).
to
eq
(
1
)
expect
(
count_data
[
:status_page_projects
]).
to
eq
(
1
)
expect
(
count_data
[
:status_page_issues
]).
to
eq
(
1
)
...
...
@@ -423,21 +417,6 @@ RSpec.describe Gitlab::UsageData do
end
end
describe
'usage_activity_by_stage_package'
do
it
'includes accurate usage_activity_by_stage data'
do
for_defined_days_back
do
create
(
:project
,
packages:
[
create
(
:package
)]
)
end
expect
(
described_class
.
usage_activity_by_stage_package
({})).
to
eq
(
projects_with_packages:
2
)
expect
(
described_class
.
usage_activity_by_stage_package
(
described_class
.
last_28_days_time_period
)).
to
eq
(
projects_with_packages:
1
)
end
end
describe
'usage_activity_by_stage_plan'
do
it
'includes accurate usage_activity_by_stage data'
do
stub_licensed_features
(
board_assignee_lists:
true
,
board_milestone_lists:
true
)
...
...
lib/gitlab/usage_data.rb
View file @
560de38b
...
...
@@ -129,6 +129,7 @@ module Gitlab
lfs_objects:
count
(
LfsObject
),
milestone_lists:
count
(
List
.
milestone
),
milestones:
count
(
Milestone
),
projects_with_packages:
distinct_count
(
::
Packages
::
Package
,
:project_id
),
pages_domains:
count
(
PagesDomain
),
pool_repositories:
count
(
PoolRepository
),
projects:
count
(
Project
),
...
...
@@ -527,9 +528,13 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
usage_activity_by_stage_package
(
time_period
)
{}
{
projects_with_packages:
distinct_count
(
::
Project
.
with_packages
.
where
(
time_period
),
:creator_id
)
}
end
# rubocop: enable CodeReuse/ActiveRecord
# Omitted because no user, creator or author associated: `boards`, `labels`, `milestones`, `uploads`
# Omitted because too expensive: `epics_deepest_relationship_level`
...
...
spec/factories/usage_data.rb
View file @
560de38b
...
...
@@ -94,6 +94,10 @@ FactoryBot.define do
create
(
:grafana_integration
,
project:
projects
[
1
],
enabled:
true
)
create
(
:grafana_integration
,
project:
projects
[
2
],
enabled:
false
)
create
(
:package
,
project:
projects
[
0
])
create
(
:package
,
project:
projects
[
0
])
create
(
:package
,
project:
projects
[
1
])
ProjectFeature
.
first
.
update_attribute
(
'repository_access_level'
,
0
)
# Create fresh & a month (28-days SMAU) old data
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
560de38b
...
...
@@ -56,6 +56,21 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe
'usage_activity_by_stage_package'
do
it
'includes accurate usage_activity_by_stage data'
do
for_defined_days_back
do
create
(
:project
,
packages:
[
create
(
:package
)]
)
end
expect
(
described_class
.
usage_activity_by_stage_package
({})).
to
eq
(
projects_with_packages:
2
)
expect
(
described_class
.
usage_activity_by_stage_package
(
described_class
.
last_28_days_time_period
)).
to
eq
(
projects_with_packages:
1
)
end
end
describe
'.usage_activity_by_stage_configure'
do
it
'includes accurate usage_activity_by_stage data'
do
for_defined_days_back
do
...
...
@@ -399,6 +414,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect
(
count_data
[
:snippets
]).
to
eq
(
6
)
expect
(
count_data
[
:personal_snippets
]).
to
eq
(
2
)
expect
(
count_data
[
:project_snippets
]).
to
eq
(
4
)
expect
(
count_data
[
:projects_with_packages
]).
to
eq
(
2
)
end
it
'gathers object store usage correctly'
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