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
df742a89
Commit
df742a89
authored
Nov 26, 2019
by
minghuan lei
Committed by
Imre Farkas
Nov 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add template repository usage to the usage ping
parent
5bb90b56
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
1 deletion
+41
-1
changelogs/unreleased/7597-add-template-repository-usage-to-the-usage-ping.yml
.../7597-add-template-repository-usage-to-the-usage-ping.yml
+5
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+2
-1
ee/spec/lib/gitlab/usage_data_spec.rb
ee/spec/lib/gitlab/usage_data_spec.rb
+1
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+31
-0
No files found.
changelogs/unreleased/7597-add-template-repository-usage-to-the-usage-ping.yml
0 → 100644
View file @
df742a89
---
title
:
Add template repository usage to the usage ping
merge_request
:
20126
author
:
minghuan lei
type
:
changed
ee/app/models/ee/project.rb
View file @
df742a89
...
@@ -144,6 +144,8 @@ module EE
...
@@ -144,6 +144,8 @@ module EE
scope
:with_slack_slash_commands_service
,
->
{
joins
(
:slack_slash_commands_service
)
}
scope
:with_slack_slash_commands_service
,
->
{
joins
(
:slack_slash_commands_service
)
}
scope
:with_prometheus_service
,
->
{
joins
(
:prometheus_service
)
}
scope
:with_prometheus_service
,
->
{
joins
(
:prometheus_service
)
}
scope
:aimed_for_deletion
,
->
(
date
)
{
where
(
'marked_for_deletion_at <= ?'
,
date
).
without_deleted
}
scope
:aimed_for_deletion
,
->
(
date
)
{
where
(
'marked_for_deletion_at <= ?'
,
date
).
without_deleted
}
scope
:with_repos_templates
,
->
{
where
(
namespace_id:
::
Gitlab
::
CurrentSettings
.
current_application_settings
.
custom_project_templates_group_id
)
}
scope
:with_groups_level_repos_templates
,
->
{
joins
(
"INNER JOIN namespaces ON projects.namespace_id = namespaces.custom_project_templates_group_id"
)
}
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
to: :statistics
,
allow_nil:
true
to: :statistics
,
allow_nil:
true
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
df742a89
...
@@ -138,7 +138,8 @@ module EE
...
@@ -138,7 +138,8 @@ module EE
projects_with_packages:
count
(
::
Packages
::
Package
.
select
(
'distinct project_id'
)),
projects_with_packages:
count
(
::
Packages
::
Package
.
select
(
'distinct project_id'
)),
projects_with_prometheus_alerts:
count
(
PrometheusAlert
.
distinct_projects
),
projects_with_prometheus_alerts:
count
(
PrometheusAlert
.
distinct_projects
),
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
),
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
),
projects_with_alerts_service_enabled:
count
(
AlertsService
.
active
)
projects_with_alerts_service_enabled:
count
(
AlertsService
.
active
),
template_repositories:
count
(
::
Project
.
with_repos_templates
)
+
count
(
::
Project
.
with_groups_level_repos_templates
)
},
},
service_desk_counts
,
service_desk_counts
,
security_products_usage
,
security_products_usage
,
...
...
ee/spec/lib/gitlab/usage_data_spec.rb
View file @
df742a89
...
@@ -93,6 +93,7 @@ describe Gitlab::UsageData do
...
@@ -93,6 +93,7 @@ describe Gitlab::UsageData do
design_management_designs_delete
design_management_designs_delete
user_preferences_group_overview_details
user_preferences_group_overview_details
user_preferences_group_overview_security_dashboard
user_preferences_group_overview_security_dashboard
template_repositories
)
)
)
)
expect
(
count_data
[
:projects_with_prometheus_alerts
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_with_prometheus_alerts
]).
to
eq
(
2
)
...
...
ee/spec/models/project_spec.rb
View file @
df742a89
...
@@ -2352,4 +2352,35 @@ describe Project do
...
@@ -2352,4 +2352,35 @@ describe Project do
end
end
end
end
end
end
describe
'caculate template repositories'
do
let
(
:group1
)
{
create
(
:group
)
}
let
(
:group2
)
{
create
(
:group
)
}
let
(
:group2_sub1
)
{
create
(
:group
,
parent:
group2
)
}
let
(
:group2_sub2
)
{
create
(
:group
,
parent:
group2
)
}
before
do
stub_ee_application_setting
(
custom_project_templates_group_id:
group2
.
id
)
group2
.
update
(
custom_project_templates_group_id:
group2_sub2
.
id
)
create
(
:project
,
group:
group1
)
2
.
times
do
create
(
:project
,
group:
group2
)
end
3
.
times
do
create
(
:project
,
group:
group2_sub1
)
end
4
.
times
do
create
(
:project
,
group:
group2_sub2
)
end
end
it
'counts instance level templates'
do
expect
(
described_class
.
with_repos_templates
.
count
).
to
eq
(
2
)
end
it
'counts group level templates'
do
expect
(
described_class
.
with_groups_level_repos_templates
.
count
).
to
eq
(
4
)
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