summaryrefslogtreecommitdiff
path: root/app/services/users/activity_service.rb
blob: 5803404c3c8c83665f8758321c461ae1342f1309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Users
  class ActivityService
    def initialize(author, activity)
      @author = author.respond_to?(:user) ? author.user : author
      @activity = activity
    end

    def execute
      return unless @author && @author.is_a?(User)

      record_activity
    end

    private

    def record_activity
      Gitlab::UserActivities.record(@author.id) if Gitlab::Database.read_write?

      Rails.logger.debug("Recorded activity: #{@activity} for User ID: #{@author.id} (username: #{@author.username})")
    end
  end
end