2018-11-08 19:23:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module NewIssuable
|
|
|
|
attr_reader :issuable, :user
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def objects_found?(issuable_id, user_id)
|
|
|
|
set_user(user_id)
|
|
|
|
set_issuable(issuable_id)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
user && issuable
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
def set_user(user_id)
|
|
|
|
@user = User.find_by(id: user_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
|
|
|
|
|
|
|
log_error(User, user_id) unless @user # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
def set_issuable(issuable_id)
|
|
|
|
@issuable = issuable_class.find_by(id: issuable_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
log_error(issuable_class, issuable_id) unless @issuable # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
def log_error(record_class, record_id)
|
2019-09-30 21:07:59 +05:30
|
|
|
Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") # rubocop:disable Gitlab/RailsLogger
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|