Commit 632e9d30 authored by Alper Akgun's avatar Alper Akgun

Add usage ping count for events distinct author_id

As part of usage ping, I would want to know how many users are
creating events (https://docs.gitlab.com/ee/api/events.html)
parent 5c2c6c72
......@@ -6,6 +6,8 @@ module EE
extend ::Gitlab::Utils::Override
prepended do
include UsageStatistics
scope :issues, -> { where(target_type: 'Issue') }
scope :merge_requests, -> { where(target_type: 'MergeRequest') }
scope :created, -> { where(action: ::Event::CREATED) }
......
---
title: Add usage ping counter for events
merge_request: 199874
author:
type: added
......@@ -233,6 +233,7 @@ module EE
# Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links`
def usage_activity_by_stage_manage
{
events: ::Event.distinct_count_by(:author_id),
groups: ::GroupMember.distinct_count_by(:user_id),
ldap_keys: ::LDAPKey.distinct_count_by(:user_id),
ldap_users: ::GroupMember.of_ldap_type.distinct_count_by(:user_id)
......
......@@ -111,11 +111,13 @@ describe Gitlab::UsageData do
context 'for manage' do
it 'includes accurate usage_activity_by_stage data' do
user = create(:user)
create(:event, author: user)
create(:group_member, user: user)
create(:key, type: 'LDAPKey', user: user)
create(:group_member, ldap: true, user: user)
expect(described_class.uncached_data[:usage_activity_by_stage][:manage]).to eq(
events: 1,
groups: 1,
ldap_keys: 1,
ldap_users: 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment