Commit bc0228c3 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fj-219399-add-usage-data-monthly-snippet-by-type' into 'master'

Add personal and project snippet monthly counters to usage data

See merge request gitlab-org/gitlab!35155
parents b7c070f1 963b08ee
---
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
| `releases` | `counts` | `release` | | | Unique release tags |
| `remote_mirrors` | `counts` | | | | |
| `requirements_created` | `counts` | | | | |
| `snippets` | `counts` | 'create' | | | |
| `snippets` | `counts_monthly` | 'create' | | | |
| `snippets` | `counts` | 'create' | | CE+EE | |
| `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` | | | | |
| `todos` | `counts` | | | | |
| `uploads` | `counts` | | | | |
......
......@@ -143,7 +143,6 @@ module Gitlab
protected_branches: count(ProtectedBranch),
releases: count(Release),
remote_mirrors: count(RemoteMirror),
snippets: count(Snippet),
personal_snippets: count(PersonalSnippet),
project_snippets: count(ProjectSnippet),
suggestions: count(Suggestion),
......@@ -162,7 +161,9 @@ module Gitlab
ingress_modsecurity_usage,
container_expiration_policies_usage,
merge_requests_usage(default_time_period)
)
).tap do |data|
data[:snippets] = data[:personal_snippets] + data[:project_snippets]
end
}
end
# rubocop: enable Metrics/AbcSize
......@@ -170,8 +171,11 @@ module Gitlab
def system_usage_data_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
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -92,7 +92,8 @@ FactoryBot.define do
# Create fresh & a month (28-days SMAU) old data
[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
......
......@@ -174,7 +174,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:clusters_applications_jupyter]).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
it 'gathers object store usage correctly' do
......@@ -261,7 +263,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
it 'gathers projects data correctly' do
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
......
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