Class: Users::ActivityService

Inherits:
Object
  • Object
show all
Defined in:
app/services/users/activity_service.rb

Constant Summary collapse

LEASE_TIMEOUT =
1.minute.to_i

Instance Method Summary collapse

Constructor Details

#initialize(author:, namespace: nil, project: nil) ⇒ ActivityService

Returns a new instance of ActivityService.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/users/activity_service.rb', line 7

def initialize(author:, namespace: nil, project: nil)
  @user = if author.respond_to?(:username)
            author
          elsif author.respond_to?(:user)
            author.user
          end

  @user = nil unless user.is_a?(User)
  @namespace = namespace
  @project = project
end

Instance Method Details

#executeObject



19
20
21
22
23
# File 'app/services/users/activity_service.rb', line 19

def execute
  return unless user

  ::Gitlab::Database::LoadBalancing::Session.without_sticky_writes { record_activity }
end