Draft: Add uniq user count to package usage data
What does this MR do?
Adds uniq count of users to the packages section.
New queries
Gitlab::UsageData.distinct_count(::Packages::Package.where(Gitlab::UsageData.last_28_days_time_period), :creator_id)
SELECT MIN("packages_packages"."creator_id") FROM "packages_packages" WHERE "packages_packages"."created_at" BETWEEN '2020-08-06 07:32:14.449287' AND '2020-09-03 07:32:14.449488';
Result (cost=3.45..3.46 rows=1 width=4) (actual time=4.048..4.048 rows=1 loops=1)
Buffers: shared read=3
I/O Timings: read=4.015
InitPlan 1 (returns $0)
-> Limit (cost=0.42..3.45 rows=1 width=4) (actual time=4.045..4.045 rows=0 loops=1)
Buffers: shared read=3
I/O Timings: read=4.015
-> Index Scan using index_packages_packages_on_creator_id on public.packages_packages (cost=0.42..3.45 rows=1 width=4) (actual time=4.043..4.044 rows=0 loops=1)
Index Cond: (packages_packages.creator_id IS NOT NULL)
Filter: ((packages_packages.created_at >= '2020-08-06 07:32:14.449287+00'::timestamp with time zone) AND (packages_packages.created_at <= '2020-09-03 07:32:14.449488+00'::timestamp with time zone))
Rows Removed by Filter: 0
Buffers: shared read=3
SELECT MAX("packages_packages"."creator_id") FROM "packages_packages" WHERE "packages_packages"."created_at" BETWEEN '2020-08-06 07:32:14.449287' AND '2020-09-03 07:32:14.449488';
Result (cost=3.45..3.46 rows=1 width=4) (actual time=0.061..0.061 rows=1 loops=1)
Buffers: shared hit=3
InitPlan 1 (returns $0)
-> Limit (cost=0.42..3.45 rows=1 width=4) (actual time=0.057..0.057 rows=0 loops=1)
Buffers: shared hit=3
-> Index Scan using index_packages_packages_on_creator_id on public.packages_packages (cost=0.42..3.45 rows=1 width=4) (actual time=0.055..0.055 rows=0 loops=1)
Index Cond: (packages_packages.creator_id IS NOT NULL)
Filter: ((packages_packages.created_at >= '2020-08-06 07:32:14.449287+00'::timestamp with time zone) AND (packages_packages.created_at <= '2020-09-03 07:32:14.449488+00'::timestamp with time zone))
Rows Removed by Filter: 0
Buffers: shared hit=3
SELECT COUNT(DISTINCT "packages_packages"."creator_id") FROM "packages_packages" WHERE "packages_packages"."created_at" BETWEEN '2020-08-06 07:32:14.449287' AND '2020-09-03 07:32:14.449488' AND "packages_packages"."creator_id" BETWEEN 0 AND 9999
Aggregate (cost=3.45..3.46 rows=1 width=8) (actual time=0.135..0.136 rows=1 loops=1)
Buffers: shared hit=6
-> Index Scan using index_packages_packages_on_creator_id on public.packages_packages (cost=0.42..3.45 rows=1 width=4) (actual time=0.019..0.019 rows=0 loops=1)
Index Cond: ((packages_packages.creator_id >= 0) AND (packages_packages.creator_id <= 9999))
Filter: ((packages_packages.created_at >= '2020-08-06 07:32:14.449287+00'::timestamp with time zone) AND (packages_packages.created_at <= '2020-09-03 07:32:14.449488+00'::timestamp with time zone))
Rows Removed by Filter: 0
Buffers: shared hit=3
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
Part of #205578 (closed)
Edited by Giorgenes Gelatti