Add codeowners to usage data
What does this MR do?
Related to #227429 (closed) This MR adds a usage data to answer the following:
- Out of the total number of codeowners files, how many of those files are making use of the sectional codeowners feature?
SELECT MIN("projects"."id") FROM "projects"
Explain: https://explain.depesz.com/s/qwoS Time: 0.816 ms
SELECT MAX("projects"."id") FROM "projects"
Explain: https://explain.depesz.com/s/7PJa Time: 0.900 ms
Optimization
CREATE INDEX index_created_at_on_codeowner_approval_merge_request_rules ON public.approval_merge_request_rules USING btree (created_at) WHERE ((rule_type = 2) AND (section <> 'codeowners'::text))
Duration: 12.600 s
With Time Period:
SELECT COUNT(DISTINCT merge_requests.target_project_id) FROM “approval_merge_request_rules” INNER JOIN “merge_requests” ON “merge_requests”.“id” = “approval_merge_request_rules”.“merge_request_id” WHERE “approval_merge_request_rules”.“rule_type” = 2 AND (section != ‘codeowners’) AND “approval_merge_request_rules”.“created_at” BETWEEN ‘2020-07-21 08:14:21.186258’ AND ‘2020-08-18 08:14:21.186414’ AND “merge_requests”.“target_project_id” BETWEEN 1 AND 10000
BEFORE: Explain: https://explain.depesz.com/s/Do1O Time: 324.813 ms
AFTER: Explain: https://explain.depesz.com/s/rDrV Time: 20.592 ms
Without Time Period:
SELECT COUNT(DISTINCT merge_requests.target_project_id) FROM “approval_merge_request_rules” INNER JOIN “merge_requests” ON “merge_requests”.“id” = “approval_merge_request_rules”.“merge_request_id” WHERE “approval_merge_request_rules”.“rule_type” = 2 AND (section != ‘codeowners’) AND “merge_requests”.“target_project_id” BETWEEN 1 AND 10000
BEFORE: Explain: https://explain.depesz.com/s/MqMR Time: 84.048 ms
AFTER: Explain: https://explain.depesz.com/s/1eV8 Time: 21.189 ms
Migration Output
$ VERBOSE=true bundle exec rake db:migrate:up VERSION=20200817100710
== 20200817100710 AddSectionAndCreatedAtCodeownerApprovalMergeRequestIndex: migrating
-- transaction_open?()
-> 0.0000s
-- index_exists?(:approval_merge_request_rules, :created_at, {:where=>"rule_type = 2 AND section != 'codeowners'::text", :name=>"index_created_at_on_codeowner_approval_merge_request_rules", :algorithm=>:concurrently})
-> 0.0042s
-- add_index(:approval_merge_request_rules, :created_at, {:where=>"rule_type = 2 AND section != 'codeowners'::text", :name=>"index_created_at_on_codeowner_approval_merge_request_rules", :algorithm=>:concurrently})
-> 0.0031s
== 20200817100710 AddSectionAndCreatedAtCodeownerApprovalMergeRequestIndex: migrated (0.0077s)
$ VERBOSE=true bundle exec rake db:migrate:down VERSION=20200817100710
== 20200817100710 AddSectionAndCreatedAtCodeownerApprovalMergeRequestIndex: reverting
-- transaction_open?()
-> 0.0000s
-- indexes(:approval_merge_request_rules)
-> 0.0045s
-- remove_index(:approval_merge_request_rules, {:algorithm=>:concurrently, :name=>"index_created_at_on_codeowner_approval_merge_request_rules"})
-> 0.0031s
== 20200817100710 AddSectionAndCreatedAtCodeownerApprovalMergeRequestIndex: reverted (0.0079s)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #227429 (closed)
Edited by Sincheol (David) Kim