2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UpdateHighestRoleWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
feature_category :utilization
|
2020-04-22 19:07:51 +05:30
|
|
|
urgency :high
|
|
|
|
weight 2
|
|
|
|
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
def perform(user_id)
|
|
|
|
user = User.find_by(id: user_id)
|
|
|
|
|
|
|
|
return unless user.present?
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
if user.active? && user.human? && !user.internal?
|
2020-04-22 19:07:51 +05:30
|
|
|
Users::UpdateHighestMemberRoleService.new(user).execute
|
|
|
|
else
|
|
|
|
UserHighestRole.where(user_id: user_id).delete_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|