2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UpdateHighestRoleWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
data_consistency :always
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
feature_category :subscription_usage_reports
|
2020-04-22 19:07:51 +05:30
|
|
|
urgency :high
|
|
|
|
weight 2
|
|
|
|
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
def perform(user_id)
|
2021-12-11 22:18:48 +05:30
|
|
|
user = User.find_by_id(user_id)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
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
|
2021-12-11 22:18:48 +05:30
|
|
|
UserHighestRole.where(user_id: user_id).delete_all # rubocop: disable CodeReuse/ActiveRecord
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|