Commit 4ed16b49 authored by Alex Buijs's avatar Alex Buijs Committed by Mayra Cabrera

Add usage statistics data for package stage

Added usage activity data for package stage
parent 24a05675
......@@ -122,6 +122,7 @@ module EE
scope :with_active_prometheus_service, -> { joins(:prometheus_service).merge(PrometheusService.active) }
scope :with_enabled_error_tracking, -> { joins(:error_tracking_setting).where(project_error_tracking_settings: { enabled: true }) }
scope :with_tracing_enabled, -> { joins(:tracing_setting) }
scope :with_packages, -> { joins(:packages) }
delegate :shared_runners_minutes, :shared_runners_seconds, :shared_runners_seconds_last_reset,
to: :statistics, allow_nil: true
......
......@@ -186,6 +186,7 @@ module EE
create: usage_activity_by_stage_create,
manage: usage_activity_by_stage_manage,
monitor: usage_activity_by_stage_monitor,
package: usage_activity_by_stage_package,
plan: usage_activity_by_stage_plan,
verify: usage_activity_by_stage_verify
}
......@@ -229,6 +230,12 @@ module EE
}
end
def usage_activity_by_stage_package
{
projects_with_packages: ::Project.with_packages.distinct_count_by(:creator_id)
}
end
# Omitted because no user, creator or author associated: `boards`, `labels`, `milestones`, `uploads`
# Omitted because too expensive: `epics_deepest_relationship_level`
# Omitted because of encrypted properties: `projects_jira_cloud_active`, `projects_jira_server_active`
......
......@@ -107,6 +107,16 @@ describe Gitlab::UsageData do
end
end
context 'for package' do
it 'includes accurate usage_activity_by_stage data' do
create(:project, packages: [create(:package)] )
expect(described_class.uncached_data[:usage_activity_by_stage][:package]).to eq(
projects_with_packages: 1
)
end
end
context 'for plan' do
it 'includes accurate usage_activity_by_stage data' do
stub_licensed_features(board_assignee_lists: true, board_milestone_lists: true)
......
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