Skip to content

Add unique DiffNote author count to usage ping

What does this MR do?

Adds DiffNote usage to usage ping. This should help us answer the question: How many unique users have used DiffNotes?

SELECT COUNT(DISTINCT “notes”.“author_id”) FROM “notes” WHERE “notes”.“type” = ‘DiffNote’ AND “notes”.“author_id” BETWEEN 1 AND 10000

# Unbound time period
#
 Aggregate  (cost=2024293.60..2024293.61 rows=1 width=8) (actual time=1564527.233..1564527.234 rows=1 loops=1)
   Buffers: shared hit=208871 read=1088133 dirtied=20955 written=1
   I/O Timings: read=1542868.543 write=0.201
   ->  Index Scan using index_notes_on_author_id_and_created_at_and_id on public.notes  (cost=0.57..2023952.61 rows=136397 width=4) (actual time=28330.697..1564215.345 rows=102093 loops=1)
         Index Cond: ((notes.author_id >= 1) AND (notes.author_id <= 10000))
         Filter: ((notes.type)::text = 'DiffNote'::text)
         Rows Removed by Filter: 1276350
         Buffers: shared hit=208862 read=1088133 dirtied=20955 written=1
         I/O Timings: read=1542868.543 write=0.201

# trailing 28 days
#
Aggregate  (cost=110713.00..110713.01 rows=1 width=8)
  ->  Index Scan using index_notes_on_author_id_and_created_at_and_id on notes  (cost=0.57..110700.62 rows=4952 width=4)
        Index Cond: ((author_id >= 1) AND (author_id <= 10000) AND (created_at >= '2020-06-30 18:26:56.401866+00'::timestamp with time zone) AND (created_at <= '2020-07-28 18:26:56.402014+00'::timestamp with time zone))
        Filter: ((type)::text = 'DiffNote'::text)

 Aggregate  (cost=110713.00..110713.01 rows=1 width=8) (actual time=33067.244..33067.245 rows=1 loops=1)
   Buffers: shared hit=7846 read=25255 dirtied=699 written=2
   I/O Timings: read=32372.739 write=0.436
   ->  Index Scan using index_notes_on_author_id_and_created_at_and_id on public.notes  (cost=0.57..110700.62 rows=4952 width=4) (actual time=1.728..33058.856 rows=3003 loops=1)
         Index Cond: ((notes.author_id >= 1) AND (notes.author_id <= 10000) AND (notes.created_at >= '2020-06-30 18:26:56.401866+00'::timestamp with time zone) AND (notes.created_at <= '2020-07-28 18:26:56.402014+00'::timestamp with time zone))
         Filter: ((notes.type)::text = 'DiffNote'::text)
         Rows Removed by Filter: 20553
         Buffers: shared hit=7837 read=25255 dirtied=699 written=2
         I/O Timings: read=32372.739 write=0.436

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

#225555 (closed)

Edited by Kerri Miller

Merge request reports