2016-10-05 10:41:32 -04:00
|
|
|
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
|
2017-09-19 03:44:58 -04:00
|
|
|
Gitlab::UserActivities.record(@author.id) if Gitlab::Database.read_write?
|
2016-10-05 10:41:32 -04:00
|
|
|
|
2017-06-04 02:11:53 -04:00
|
|
|
Rails.logger.debug("Recorded activity: #{@activity} for User ID: #{@author.id} (username: #{@author.username})")
|
2016-10-05 10:41:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|