debian-mirror-gitlab/app/workers/update_highest_role_worker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
556 B
Ruby
Raw Normal View History

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
2021-04-29 21:17:54 +05:30
feature_category :utilization
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