Instrument usage of overridden approval rules for self-managed instances
Problem to solve
#220529 (closed) will provide us the usage for approval rules, however, we still need to know usage for overridden approval rules for merge requests (when the Can override approvals in merge request option is ticked in repo settings).
Further details
We should be able to distinguish between the two types by looking at the ApprovalMergeRequestRuleSource for an ApprovalMergeRequestRule
Proposal
From #220541 (comment 358825262):
First, we need to check which MRs have project approval rules (from
approval_project_rules) that are not a source rule of merge request approval rules (fromapproval_merge_request_rules). We need to only count the MRs that are fromprojectswithdisable_overriding_approvers_per_merge_requestasfalse. These are MRs with deleted approval rules.
Next, we need to check which MRs have merge request approval rules that have different name, approvals_required, users, or groups from their source project approval rule. Like the first list, we only need to count the MRs that are from projects with disable_overriding_approvers_per_merge_request as false. These are the MRs with edited approval rules.
We can then combine these 2 lists and distinct count by merge_request_id.