Commit 89a5f6f3 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '217362-move-release-stage-usage-activity-to-ce' into 'master'

Move release stage usage activity to CE

See merge request gitlab-org/gitlab!36083
parents 9cbb10d6 a9bb458c
---
title: Move release stage usage activity to CE
merge_request: 36083
author:
type: changed
......@@ -672,11 +672,11 @@ appear to be associated to any of the services running, since they all appear to
| `service_desk_enabled_projects` | `usage_activity_by_stage` | `plan` | | | |
| `service_desk_issues` | `usage_activity_by_stage` | `plan` | | | |
| `todos: 0` | `usage_activity_by_stage` | `plan` | | | |
| `deployments` | `usage_activity_by_stage` | `release` | | | Total deployments |
| `failed_deployments` | `usage_activity_by_stage` | `release` | | | Total failed deployments |
| `projects_mirrored_with_pipelines_enabled` | `usage_activity_by_stage` | `release` | | | Projects with repository mirroring enabled |
| `releases` | `usage_activity_by_stage` | `release` | | | Unique release tags in project |
| `successful_deployments: 0` | `usage_activity_by_stage` | `release` | | | Total successful deployments |
| `deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total deployments |
| `failed_deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total failed deployments |
| `projects_mirrored_with_pipelines_enabled` | `usage_activity_by_stage` | `release` | | EE | Projects with repository mirroring enabled |
| `releases` | `usage_activity_by_stage` | `release` | | CE+EE | Unique release tags in project |
| `successful_deployments` | `usage_activity_by_stage` | `release` | | CE+EE | Total successful deployments |
| `user_preferences_group_overview_security_dashboard: 0` | `usage_activity_by_stage` | `secure` | | | |
| `ci_builds` | `usage_activity_by_stage` | `verify` | | | Unique builds in project |
| `ci_external_pipelines` | `usage_activity_by_stage` | `verify` | | | Total pipelines in external repositories |
......
......@@ -291,11 +291,7 @@ module EE
override :usage_activity_by_stage_release
def usage_activity_by_stage_release(time_period)
super.merge({
deployments: distinct_count(::Deployment.where(time_period), :user_id),
failed_deployments: distinct_count(::Deployment.failed.where(time_period), :user_id),
projects_mirrored_with_pipelines_enabled: distinct_count(::Project.mirrored_with_enabled_pipelines.where(time_period), :creator_id),
releases: distinct_count(::Release.where(time_period), :author_id),
successful_deployments: distinct_count(::Deployment.success.where(time_period), :user_id)
projects_mirrored_with_pipelines_enabled: distinct_count(::Project.mirrored_with_enabled_pipelines.where(time_period), :creator_id)
})
end
......
......@@ -512,26 +512,14 @@ RSpec.describe Gitlab::UsageData do
context 'for release' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
create(:deployment, :failed, user: user)
create(:project, :mirror, mirror_trigger_builds: true)
create(:release, author: user)
create(:deployment, :success, user: user)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:release]).to eq(
deployments: 2,
failed_deployments: 2,
projects_mirrored_with_pipelines_enabled: 2,
releases: 2,
successful_deployments: 2
expect(described_class.uncached_data[:usage_activity_by_stage][:release]).to include(
projects_mirrored_with_pipelines_enabled: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:release]).to eq(
deployments: 1,
failed_deployments: 1,
projects_mirrored_with_pipelines_enabled: 1,
releases: 1,
successful_deployments: 1
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:release]).to include(
projects_mirrored_with_pipelines_enabled: 1
)
end
end
......
......@@ -520,9 +520,16 @@ module Gitlab
end
# Omitted because no user, creator or author associated: `environments`, `feature_flags`, `in_review_folder`, `pages_domains`
# rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_release(time_period)
{}
{
deployments: distinct_count(::Deployment.where(time_period), :user_id),
failed_deployments: distinct_count(::Deployment.failed.where(time_period), :user_id),
releases: distinct_count(::Release.where(time_period), :author_id),
successful_deployments: distinct_count(::Deployment.success.where(time_period), :user_id)
}
end
# rubocop: enable CodeReuse/ActiveRecord
# Omitted because no user, creator or author associated: `ci_runners`
def usage_activity_by_stage_verify(time_period)
......
......@@ -159,6 +159,30 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
context 'for release' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
create(:deployment, :failed, user: user)
create(:release, author: user)
create(:deployment, :success, user: user)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:release]).to include(
deployments: 2,
failed_deployments: 2,
releases: 2,
successful_deployments: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:release]).to include(
deployments: 1,
failed_deployments: 1,
releases: 1,
successful_deployments: 1
)
end
end
it 'ensures recorded_at is set before any other usage data calculation' do
%i(alt_usage_data redis_usage_data distinct_count count).each do |method|
expect(described_class).not_to receive(method)
......
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