Commit 6a9c2b82 authored by charlie ablett's avatar charlie ablett

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

Move verify stage usage activity to CE

See merge request gitlab-org/gitlab!36090
parents bf211755 c6b7fd99
---
title: Move verify stage usage activity to CE
merge_request: 36090
author:
type: changed
......@@ -678,16 +678,16 @@ appear to be associated to any of the services running, since they all appear to
| `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 |
| `ci_internal_pipelines` | `usage_activity_by_stage` | `verify` | | | Total pipelines in GitLab repositories |
| `ci_pipeline_config_auto_devops` | `usage_activity_by_stage` | `verify` | | | Total pipelines from an Auto DevOps template |
| `ci_pipeline_config_repository` | `usage_activity_by_stage` | `verify` | | | Pipelines from templates in repository |
| `ci_pipeline_schedules` | `usage_activity_by_stage` | `verify` | | | Pipeline schedules in GitLab |
| `ci_pipelines` | `usage_activity_by_stage` | `verify` | | | Total pipelines |
| `ci_triggers` | `usage_activity_by_stage` | `verify` | | | Triggers enabled |
| `clusters_applications_runner` | `usage_activity_by_stage` | `verify` | | | Unique clusters with Runner enabled |
| `projects_reporting_ci_cd_back_to_github: 0` | `usage_activity_by_stage` | `verify` | | | Unique projects with a GitHub pipeline enabled |
| `ci_builds` | `usage_activity_by_stage` | `verify` | | CE+EE | Unique builds in project |
| `ci_external_pipelines` | `usage_activity_by_stage` | `verify` | | CE+EE | Total pipelines in external repositories |
| `ci_internal_pipelines` | `usage_activity_by_stage` | `verify` | | CE+EE | Total pipelines in GitLab repositories |
| `ci_pipeline_config_auto_devops` | `usage_activity_by_stage` | `verify` | | CE+EE | Total pipelines from an Auto DevOps template |
| `ci_pipeline_config_repository` | `usage_activity_by_stage` | `verify` | | CE+EE | Pipelines from templates in repository |
| `ci_pipeline_schedules` | `usage_activity_by_stage` | `verify` | | CE+EE | Pipeline schedules in GitLab |
| `ci_pipelines` | `usage_activity_by_stage` | `verify` | | CE+EE | Total pipelines |
| `ci_triggers` | `usage_activity_by_stage` | `verify` | | CE+EE | Triggers enabled |
| `clusters_applications_runner` | `usage_activity_by_stage` | `verify` | | CE+EE | Unique clusters with Runner enabled |
| `projects_reporting_ci_cd_back_to_github` | `usage_activity_by_stage` | `verify` | | EE | Unique projects with a GitHub pipeline enabled |
| `merge_requests_users` | `usage_activity_by_stage_monthly` | `create` | | | Unique count of users who used a merge request |
| `duration_s` | `topology` | `enablement` | | | Time it took to collect topology data |
| `application_requests_per_hour` | `topology` | `enablement` | | | Number of requests to the web application per hour |
......
......@@ -299,15 +299,6 @@ module EE
override :usage_activity_by_stage_verify
def usage_activity_by_stage_verify(time_period)
super.merge({
ci_builds: distinct_count(::Ci::Build.where(time_period), :user_id),
ci_external_pipelines: distinct_count(::Ci::Pipeline.external.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_internal_pipelines: distinct_count(::Ci::Pipeline.internal.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_config_auto_devops: distinct_count(::Ci::Pipeline.auto_devops_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_config_repository: distinct_count(::Ci::Pipeline.repository_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_schedules: distinct_count(::Ci::PipelineSchedule.where(time_period), :owner_id),
ci_pipelines: distinct_count(::Ci::Pipeline.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_triggers: distinct_count(::Ci::Trigger.where(time_period), :owner_id),
clusters_applications_runner: cluster_applications_user_distinct_count(::Clusters::Applications::Runner, time_period),
projects_reporting_ci_cd_back_to_github: distinct_count(::Project.with_github_service_pipeline_events.where(time_period), :creator_id)
})
end
......
......@@ -609,40 +609,13 @@ RSpec.describe Gitlab::UsageData do
context 'for verify' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
create(:ci_build, user: user)
create(:ci_empty_pipeline, source: :external, user: user)
create(:ci_empty_pipeline, user: user)
create(:ci_pipeline, :auto_devops_source, user: user)
create(:ci_pipeline, :repository_source, user: user)
create(:ci_pipeline_schedule, owner: user)
create(:ci_trigger, owner: user)
create(:clusters_applications_runner, :installed)
create(:github_service)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:verify]).to eq(
ci_builds: 2,
ci_external_pipelines: 2,
ci_internal_pipelines: 2,
ci_pipeline_config_auto_devops: 2,
ci_pipeline_config_repository: 2,
ci_pipeline_schedules: 2,
ci_pipelines: 2,
ci_triggers: 2,
clusters_applications_runner: 2,
expect(described_class.uncached_data[:usage_activity_by_stage][:verify]).to include(
projects_reporting_ci_cd_back_to_github: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:verify]).to eq(
ci_builds: 1,
ci_external_pipelines: 1,
ci_internal_pipelines: 1,
ci_pipeline_config_auto_devops: 1,
ci_pipeline_config_repository: 1,
ci_pipeline_schedules: 1,
ci_pipelines: 1,
ci_triggers: 1,
clusters_applications_runner: 1,
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:verify]).to include(
projects_reporting_ci_cd_back_to_github: 1
)
end
......
......@@ -532,9 +532,21 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord
# Omitted because no user, creator or author associated: `ci_runners`
# rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_verify(time_period)
{}
{
ci_builds: distinct_count(::Ci::Build.where(time_period), :user_id),
ci_external_pipelines: distinct_count(::Ci::Pipeline.external.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_internal_pipelines: distinct_count(::Ci::Pipeline.internal.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_config_auto_devops: distinct_count(::Ci::Pipeline.auto_devops_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_config_repository: distinct_count(::Ci::Pipeline.repository_source.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_pipeline_schedules: distinct_count(::Ci::PipelineSchedule.where(time_period), :owner_id),
ci_pipelines: distinct_count(::Ci::Pipeline.where(time_period), :user_id, start: user_minimum_id, finish: user_maximum_id),
ci_triggers: distinct_count(::Ci::Trigger.where(time_period), :owner_id),
clusters_applications_runner: cluster_applications_user_distinct_count(::Clusters::Applications::Runner, time_period)
}
end
# rubocop: enable CodeReuse/ActiveRecord
# Currently too complicated and to get reliable counts for these stats:
# container_scanning_jobs, dast_jobs, dependency_scanning_jobs, license_management_jobs, sast_jobs, secret_detection_jobs
......
......@@ -119,6 +119,45 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
]
end
end
context 'for verify' do
it 'includes accurate usage_activity_by_stage data' do
for_defined_days_back do
user = create(:user)
create(:ci_build, user: user)
create(:ci_empty_pipeline, source: :external, user: user)
create(:ci_empty_pipeline, user: user)
create(:ci_pipeline, :auto_devops_source, user: user)
create(:ci_pipeline, :repository_source, user: user)
create(:ci_pipeline_schedule, owner: user)
create(:ci_trigger, owner: user)
create(:clusters_applications_runner, :installed)
end
expect(described_class.uncached_data[:usage_activity_by_stage][:verify]).to include(
ci_builds: 2,
ci_external_pipelines: 2,
ci_internal_pipelines: 2,
ci_pipeline_config_auto_devops: 2,
ci_pipeline_config_repository: 2,
ci_pipeline_schedules: 2,
ci_pipelines: 2,
ci_triggers: 2,
clusters_applications_runner: 2
)
expect(described_class.uncached_data[:usage_activity_by_stage_monthly][:verify]).to include(
ci_builds: 1,
ci_external_pipelines: 1,
ci_internal_pipelines: 1,
ci_pipeline_config_auto_devops: 1,
ci_pipeline_config_repository: 1,
ci_pipeline_schedules: 1,
ci_pipelines: 1,
ci_triggers: 1,
clusters_applications_runner: 1
)
end
end
end
context 'for create' do
......
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