Class: Packages::CreateEventService

Inherits:
BaseService show all
Defined in:
app/services/packages/create_event_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/packages/create_event_service.rb', line 5

def execute
  ::Packages::Event.unique_counters_for(event_scope, event_name, originator_type).each do |event_name|
    ::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: current_user.id)
  end

  ::Packages::Event.counters_for(event_scope, event_name, originator_type).each do |event_name|
    ::Gitlab::UsageDataCounters::PackageEventCounter.count(event_name)
  end

  if Feature.enabled?(:collect_package_events) && Gitlab::Database.read_write?
    ::Packages::Event.create!(
      event_type: event_name,
      originator: current_user&.id,
      originator_type: originator_type,
      event_scope: event_scope
    )
  end
end