Commit 9fe418ba authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '199874-add-new-usage-ping-counter-for-events' into 'master'

Add usage ping counter for events table

See merge request gitlab-org/gitlab!24111
parents b5264142 632e9d30
...@@ -6,6 +6,8 @@ module EE ...@@ -6,6 +6,8 @@ module EE
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
prepended do prepended do
include UsageStatistics
scope :issues, -> { where(target_type: 'Issue') } scope :issues, -> { where(target_type: 'Issue') }
scope :merge_requests, -> { where(target_type: 'MergeRequest') } scope :merge_requests, -> { where(target_type: 'MergeRequest') }
scope :created, -> { where(action: ::Event::CREATED) } 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 ...@@ -233,6 +233,7 @@ module EE
# Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links` # Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links`
def usage_activity_by_stage_manage def usage_activity_by_stage_manage
{ {
events: ::Event.distinct_count_by(:author_id),
groups: ::GroupMember.distinct_count_by(:user_id), groups: ::GroupMember.distinct_count_by(:user_id),
ldap_keys: ::LDAPKey.distinct_count_by(:user_id), ldap_keys: ::LDAPKey.distinct_count_by(:user_id),
ldap_users: ::GroupMember.of_ldap_type.distinct_count_by(:user_id) ldap_users: ::GroupMember.of_ldap_type.distinct_count_by(:user_id)
......
...@@ -111,11 +111,13 @@ describe Gitlab::UsageData do ...@@ -111,11 +111,13 @@ describe Gitlab::UsageData do
context 'for manage' do context 'for manage' do
it 'includes accurate usage_activity_by_stage data' do it 'includes accurate usage_activity_by_stage data' do
user = create(:user) user = create(:user)
create(:event, author: user)
create(:group_member, user: user) create(:group_member, user: user)
create(:key, type: 'LDAPKey', user: user) create(:key, type: 'LDAPKey', user: user)
create(:group_member, ldap: true, user: user) create(:group_member, ldap: true, user: user)
expect(described_class.uncached_data[:usage_activity_by_stage][:manage]).to eq( expect(described_class.uncached_data[:usage_activity_by_stage][:manage]).to eq(
events: 1,
groups: 1, groups: 1,
ldap_keys: 1, ldap_keys: 1,
ldap_users: 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