Add confidential epics count to usage data
What does this MR do?
Track number of created confidential epics in usage data.
Related to #218001 (closed)
Usage ping queries
[1] pry(main)> Gitlab::UsageData.count(::Epic.confidential)
(3.1ms) SELECT MIN("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE
(1.2ms) SELECT MAX("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE
(1.2ms) SELECT COUNT("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE AND "epics"."id" BETWEEN 3 AND 1000002
DB migration
up:
== 20200519115908 AddEpicsConfidentialIndex: migrating ========================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:epics, :confidential, {:algorithm=>:concurrently})
-> 0.0034s
-- add_index(:epics, :confidential, {:algorithm=>:concurrently})
-> 0.0052s
== 20200519115908 AddEpicsConfidentialIndex: migrated (0.0088s) ===============
down:
== 20200519115908 AddEpicsConfidentialIndex: reverting ========================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:epics, :confidential, {:algorithm=>:concurrently})
-> 0.0036s
-- remove_index(:epics, {:algorithm=>:concurrently, :column=>:confidential})
-> 0.0053s
== 20200519115908 AddEpicsConfidentialIndex: reverted (0.0092s) ===============
DB query
Without index: https://gitlab.com/snippets/1978172
With index:
-
explain SELECT MIN("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE;
: https://explain.depesz.com/s/487s -
explain SELECT MAX("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE
: https://explain.depesz.com/s/f4Pm -
explain SELECT COUNT("epics"."id") FROM "epics" WHERE "epics"."confidential" = TRUE AND "epics"."id" BETWEEN 3 AND 1000002;
: https://explain.depesz.com/s/AvoH
Screenshots
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
Edited by Jan Provaznik