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

30 lines
899 B
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
class IssueRebalancingWorker
include ApplicationWorker
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2020-11-24 15:15:51 +05:30
idempotent!
urgency :low
feature_category :issue_tracking
2021-06-08 01:23:25 +05:30
tags :exclude_from_kubernetes
2020-11-24 15:15:51 +05:30
def perform(ignore = nil, project_id = nil)
return if project_id.nil?
project = Project.find(project_id)
2021-06-08 01:23:25 +05:30
# Temporary disable reabalancing for performance reasons
# For more information check https://gitlab.com/gitlab-com/gl-infra/production/-/issues/4321
return if project.root_namespace&.issue_repositioning_disabled?
2021-01-03 14:25:43 +05:30
# All issues are equivalent as far as we are concerned
issue = project.issues.take # rubocop: disable CodeReuse/ActiveRecord
2020-11-24 15:15:51 +05:30
IssueRebalancingService.new(issue).execute
rescue ActiveRecord::RecordNotFound, IssueRebalancingService::TooManyIssues => e
Gitlab::ErrorTracking.log_exception(e, project_id: project_id)
end
end