Commit cfc447b1 authored by Logan King's avatar Logan King

Add operations dashboard usage ping data

parent 39d2f9bc
......@@ -105,6 +105,18 @@ module EE
end
end
def operations_dashboard_usage
users_with_ops_dashboard_as_default = count(::User.active.where(dashboard: 'operations'))
#users_with_projects_added = count(UsersOpsDashboardProject.select('distinct user_id').includes(:user).merge(::User.active))
users_with_projects_added = count(UsersOpsDashboardProject.select('distinct user_id'))
{
default_dashboard: users_with_ops_dashboard_as_default,
users_with_projects_added: users_with_projects_added
}
end
override :system_usage_data
def system_usage_data
usage_data = super
......@@ -121,7 +133,8 @@ module EE
projects_with_prometheus_alerts: count(PrometheusAlert.distinct_projects),
projects_with_packages: count(::Packages::Package.select('distinct project_id')),
projects_with_tracing_enabled: count(ProjectTracingSetting),
projects_enforcing_code_owner_approval: count(::Project.without_deleted.non_archived.requiring_code_owner_approval)
projects_enforcing_code_owner_approval: count(::Project.without_deleted.non_archived.requiring_code_owner_approval),
operations_dashboard: operations_dashboard_usage
}).merge(service_desk_counts).merge(security_products_usage)
# MySql does not support recursive queries so we can't retrieve epics relationship depth
......
# frozen_string_literal: true
FactoryBot.define do
factory :users_ops_dashboard_project, class: UsersOpsDashboardProject do
user factory: :user
project factory: :project
end
end
......@@ -81,6 +81,7 @@ describe Gitlab::UsageData do
projects_jira_dvcs_cloud_active
projects_jira_dvcs_server_active
feature_flags
operations_dashboard
))
expect(count_data[:projects_with_prometheus_alerts]).to eq(2)
......@@ -205,4 +206,30 @@ describe Gitlab::UsageData do
expect(described_class.system_usage_data[:counts][:projects_enforcing_code_owner_approval]).to eq(1)
end
end
describe '#operations_dashboard_usage' do
subject { described_class.operations_dashboard_usage }
before do
blocked_user = create(:user, :blocked, dashboard: 'operations')
user_with_ops_dashboard = create(:user, dashboard: 'operations')
create(:users_ops_dashboard_project, user: blocked_user)
create(:users_ops_dashboard_project)
create(:users_ops_dashboard_project)
create(:users_ops_dashboard_project)
end
it 'gathers data on operations dashboard' do
expect(subject.keys).to include(*%i(
default_dashboard,
users_with_projects_added
))
end
it 'bases counts on active users' do
expect(subject[:default_dashboard]).to eq(1)
expect(subject[:users_with_projects_added]).to eq(3)
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