Add personal and project snippet montly counters to usage data

This commits adds the project and personal snippet count
to the monthly usage data.
parent e968773f
---
title: Add personal and project snippet monthly counters to usage data
merge_request: 35155
author:
type: changed
...@@ -469,8 +469,12 @@ appear to be associated to any of the services running, since they all appear to ...@@ -469,8 +469,12 @@ appear to be associated to any of the services running, since they all appear to
| `releases` | `counts` | `release` | | | Unique release tags | | `releases` | `counts` | `release` | | | Unique release tags |
| `remote_mirrors` | `counts` | | | | | | `remote_mirrors` | `counts` | | | | |
| `requirements_created` | `counts` | | | | | | `requirements_created` | `counts` | | | | |
| `snippets` | `counts` | 'create' | | | | | `snippets` | `counts` | 'create' | | CE+EE | |
| `snippets` | `counts_monthly` | 'create' | | | | | `snippets` | `counts_monthly` | 'create' | | CE+EE | |
| `personal_snippets` | `counts` | 'create' | | CE+EE | |
| `personal_snippets` | `counts_monthly` | 'create' | | CE+EE | |
| `project_snippets` | `counts` | 'create' | | CE+EE | |
| `project_snippets` | `counts_monthly` | 'create' | | CE+EE | |
| `suggestions` | `counts` | | | | | | `suggestions` | `counts` | | | | |
| `todos` | `counts` | | | | | | `todos` | `counts` | | | | |
| `uploads` | `counts` | | | | | | `uploads` | `counts` | | | | |
......
...@@ -143,7 +143,6 @@ module Gitlab ...@@ -143,7 +143,6 @@ module Gitlab
protected_branches: count(ProtectedBranch), protected_branches: count(ProtectedBranch),
releases: count(Release), releases: count(Release),
remote_mirrors: count(RemoteMirror), remote_mirrors: count(RemoteMirror),
snippets: count(Snippet),
personal_snippets: count(PersonalSnippet), personal_snippets: count(PersonalSnippet),
project_snippets: count(ProjectSnippet), project_snippets: count(ProjectSnippet),
suggestions: count(Suggestion), suggestions: count(Suggestion),
...@@ -162,7 +161,9 @@ module Gitlab ...@@ -162,7 +161,9 @@ module Gitlab
ingress_modsecurity_usage, ingress_modsecurity_usage,
container_expiration_policies_usage, container_expiration_policies_usage,
merge_requests_usage(default_time_period) merge_requests_usage(default_time_period)
) ).tap do |data|
data[:snippets] = data[:personal_snippets] + data[:project_snippets]
end
} }
end end
# rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/AbcSize
...@@ -170,8 +171,11 @@ module Gitlab ...@@ -170,8 +171,11 @@ module Gitlab
def system_usage_data_monthly def system_usage_data_monthly
{ {
counts_monthly: { counts_monthly: {
snippets: count(Snippet.where(default_time_period)) personal_snippets: count(PersonalSnippet.where(default_time_period)),
} project_snippets: count(ProjectSnippet.where(default_time_period))
}.tap do |data|
data[:snippets] = data[:personal_snippets] + data[:project_snippets]
end
} }
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -92,7 +92,8 @@ FactoryBot.define do ...@@ -92,7 +92,8 @@ FactoryBot.define do
# Create fresh & a month (28-days SMAU) old data # Create fresh & a month (28-days SMAU) old data
[2, 29].each do |n| [2, 29].each do |n|
create(:snippet, created_at: n.days.ago) create_list(:project_snippet, 2, project: projects[0], created_at: n.days.ago)
create(:personal_snippet, created_at: n.days.ago)
end end
end end
end end
......
...@@ -174,7 +174,9 @@ describe Gitlab::UsageData, :aggregate_failures do ...@@ -174,7 +174,9 @@ describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:clusters_applications_jupyter]).to eq(1) expect(count_data[:clusters_applications_jupyter]).to eq(1)
expect(count_data[:clusters_management_project]).to eq(1) expect(count_data[:clusters_management_project]).to eq(1)
expect(count_data[:snippets]).to eq(2) expect(count_data[:snippets]).to eq(6)
expect(count_data[:personal_snippets]).to eq(2)
expect(count_data[:project_snippets]).to eq(4)
end end
it 'gathers object store usage correctly' do it 'gathers object store usage correctly' do
...@@ -261,7 +263,9 @@ describe Gitlab::UsageData, :aggregate_failures do ...@@ -261,7 +263,9 @@ describe Gitlab::UsageData, :aggregate_failures do
it 'gathers projects data correctly' do it 'gathers projects data correctly' do
counts_monthly = subject[:counts_monthly] counts_monthly = subject[:counts_monthly]
expect(counts_monthly[:snippets]).to eq(1) expect(counts_monthly[:snippets]).to eq(3)
expect(counts_monthly[:personal_snippets]).to eq(1)
expect(counts_monthly[:project_snippets]).to eq(2)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment