Remove possible duplicates from the usage data
As @patrickbajao suggested in !35224 (comment 369625787), We have these definitions under ee/lib/ee/gitlab/usage_data.rb
.
def system_usage_data
super.tap do |usage_data
usage_data[:counts].merge!
{
...
projects_enforcing_code_owner_approval: count(::Project.without_deleted.non_archived.requiring_code_owner_approval),
merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional, :merge_request_id),
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required, :merge_request_id),
...
}
end
def usage_activity_by_stage_create(time_perioda)
super.merge({
...
projects_enforcing_code_owner_approval: distinct_count(::Project.requiring_code_owner_approval.where(time_period), :creator_id),
merge_requests_with_optional_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_optional.where(time_period), :merge_request_id),
merge_requests_with_required_codeowners: distinct_count(::ApprovalMergeRequestRule.code_owner_approval_required.where(time_period), :merge_request_id),
...
})
end
They seem like duplications which can be removed, but I wonder if they serve different purposes? Can we use the ones from usage_activity_by_stage_create
and remove the ones from system_usage_data
?
Interestingly, projects_enforcing_code_owner_approval
seem to be defined slight differently as well besides the additional time_period
query.
Would you be able to check how we are using this currently and confirm if we can clean them up? @danielgruesso