Commit 3bb9f719 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Merge branch 'fix_ar_cop_in_workers' into 'master'

Fix CodeReuse/ActiveRecord offenses in workers

See merge request gitlab-org/gitlab!74150
parents 790eea67 f9237e2d
......@@ -25,11 +25,9 @@ class AuthorizedProjectsWorker
end
end
# rubocop: disable CodeReuse/ActiveRecord
def perform(user_id)
user = User.find_by(id: user_id)
user = User.find_by_id(user_id)
user&.refresh_authorized_projects(source: self.class.name)
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -14,7 +14,7 @@ class BuildHooksWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.includes({ runner: :tags })
.find_by(id: build_id)
.find_by_id(build_id)
.try(:execute_hooks)
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -12,11 +12,9 @@ class BuildQueueWorker # rubocop:disable Scalability/IdempotentWorker
worker_resource_boundary :cpu
data_consistency :sticky
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
Ci::Build.find_by_id(build_id).try do |build|
Ci::UpdateBuildQueueService.new.tick(build)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -11,13 +11,11 @@ class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker
queue_namespace :pipeline_processing
urgency :high
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
Ci::Build.find_by_id(build_id).try do |build|
stop_environment(build) if build.stops_environment?
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -16,9 +16,8 @@ class ChatNotificationWorker # rubocop:disable Scalability/IdempotentWorker
RESCHEDULE_INTERVAL = 2.seconds
RESCHEDULE_TIMEOUT = 5.minutes
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id, reschedule_count = 0)
Ci::Build.find_by(id: build_id).try do |build|
Ci::Build.find_by_id(build_id).try do |build|
send_response(build)
end
rescue Gitlab::Chat::Output::MissingBuildSectionError
......@@ -30,7 +29,6 @@ class ChatNotificationWorker # rubocop:disable Scalability/IdempotentWorker
# the job instead of producing an error.
self.class.perform_in(RESCHEDULE_INTERVAL, build_id, reschedule_count + 1)
end
# rubocop: enable CodeReuse/ActiveRecord
def send_response(build)
Gitlab::Chat::Responder.responder_for(build).try do |responder|
......
......@@ -9,12 +9,10 @@ module Ci
sidekiq_options retry: 3
include PipelineBackgroundQueue
# rubocop: disable CodeReuse/ActiveRecord
def perform(job_id)
Ci::Build.without_archived_trace.find_by(id: job_id).try do |job|
Ci::Build.without_archived_trace.find_by_id(job_id).try do |job|
Ci::ArchiveTraceService.new.execute(job, worker_name: self.class.name)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -16,7 +16,7 @@ module Ci
ARCHIVE_TRACES_IN = 2.minutes.freeze
def perform(build_id)
return unless build = Ci::Build.find_by(id: build_id) # rubocop: disable CodeReuse/ActiveRecord
return unless build = Ci::Build.find_by_id(build_id)
return unless build.project
return if build.project.pending_delete?
......
......@@ -13,12 +13,10 @@ module Ci
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(id)
::Ci::BuildTraceChunk.find_by(id: id).try do |chunk|
::Ci::BuildTraceChunk.find_by_id(id).try do |chunk|
chunk.persist_data!
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -26,16 +26,14 @@ class ClusterUpdateAppWorker # rubocop:disable Scalability/IdempotentWorker
private
# rubocop: disable CodeReuse/ActiveRecord
def execute(app_name, app_id, project_id, scheduled_time)
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return unless project
find_application(app_name, app_id) do |app|
update_prometheus(app, scheduled_time, project)
end
end
# rubocop: enable CodeReuse/ActiveRecord
def update_prometheus(app, scheduled_time, project)
return unless app.managed_prometheus?
......
......@@ -8,9 +8,8 @@ module Gitlab
# project_id - The ID of the GitLab project to import the note into.
# hash - A Hash containing the details of the GitHub object to import.
# notify_key - The Redis key to notify upon completion, if any.
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, hash, notify_key = nil)
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return notify_waiter(notify_key) unless project
......@@ -25,7 +24,6 @@ module Gitlab
.perform_in(client.rate_limit_resets_in, project.id, hash, notify_key)
end
end
# rubocop: enable CodeReuse/ActiveRecord
def try_import(*args)
import(*args)
......
......@@ -33,13 +33,13 @@ module Gitlab
self.class.perform_in(client.rate_limit_resets_in, project.id)
end
# rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
# If the project has been marked as failed we want to bail out
# automatically.
Project.joins_import_state.where(import_state: { status: :started }).find_by(id: id)
end
# rubocop: disable CodeReuse/ActiveRecord
Project.joins_import_state.where(import_state: { status: :started }).find_by_id(id)
# rubocop: enable CodeReuse/ActiveRecord
end
def abort_on_failure
false
......
......@@ -14,7 +14,7 @@ module Gitlab
end
def perform(project_id)
project = Project.find_by(id: project_id) # rubocop: disable CodeReuse/ActiveRecord
project = Project.find_by_id(project_id)
return unless can_import?(project)
......
......@@ -10,21 +10,17 @@ module NewIssuable
user && issuable
end
# rubocop: disable CodeReuse/ActiveRecord
def set_user(user_id)
@user = User.find_by(id: user_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
@user = User.find_by_id(user_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
log_error(User, user_id) unless @user # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def set_issuable(issuable_id)
@issuable = issuable_class.find_by(id: issuable_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
@issuable = issuable_class.find_by_id(issuable_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
log_error(issuable_class, issuable_id) unless @issuable # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
# rubocop: enable CodeReuse/ActiveRecord
def log_error(record_class, record_id)
Gitlab::AppLogger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job")
......
......@@ -12,7 +12,6 @@ class CreateCommitSignatureWorker
idempotent!
loggable_arguments 0
# rubocop: disable CodeReuse/ActiveRecord
def perform(commit_shas, project_id)
# Older versions of Git::BranchPushService may push a single commit ID on
# the stack. We need this to be backwards compatible.
......@@ -20,7 +19,7 @@ class CreateCommitSignatureWorker
return if commit_shas.empty?
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return unless project
commits = project.commits_by(oids: commit_shas)
......@@ -44,5 +43,4 @@ class CreateCommitSignatureWorker
Gitlab::AppLogger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}")
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -15,10 +15,9 @@ class DeleteContainerRepositoryWorker # rubocop:disable Scalability/IdempotentWo
attr_reader :container_repository
# rubocop: disable CodeReuse/ActiveRecord
def perform(current_user_id, container_repository_id)
current_user = User.find_by(id: current_user_id)
@container_repository = ContainerRepository.find_by(id: container_repository_id)
current_user = User.find_by_id(current_user_id)
@container_repository = ContainerRepository.find_by_id(container_repository_id)
project = container_repository&.project
return unless current_user && container_repository && project
......@@ -29,7 +28,6 @@ class DeleteContainerRepositoryWorker # rubocop:disable Scalability/IdempotentWo
Projects::ContainerRepository::DestroyService.new(project, current_user).execute(container_repository)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# For ExclusiveLeaseGuard concern
def lease_key
......
......@@ -14,16 +14,14 @@ class DetectRepositoryLanguagesWorker # rubocop:disable Scalability/IdempotentWo
attr_reader :project
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id = nil)
@project = Project.find_by(id: project_id)
@project = Project.find_by_id(project_id)
return unless project
try_obtain_lease do
::Projects::DetectRepositoryLanguagesService.new(project).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -9,17 +9,17 @@ class ExpireBuildInstanceArtifactsWorker # rubocop:disable Scalability/Idempoten
feature_category :build_artifacts
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
# rubocop: disable CodeReuse/ActiveRecord
build = Ci::Build
.with_expired_artifacts
.reorder(nil)
.find_by(id: build_id)
.find_by_id(build_id)
# rubocop: enable CodeReuse/ActiveRecord
return unless build&.project && !build.project.pending_delete
Gitlab::AppLogger.info("Removing artifacts for build #{build.id}...")
build.erase_erasable_artifacts!
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -14,9 +14,8 @@ class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
deduplicate :until_executing, including_scheduled: true
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(job_id)
job = CommitStatus.preload(:pipeline, :project).find_by(id: job_id)
job = CommitStatus.preload(:pipeline, :project).find_by_id(job_id) # rubocop: disable CodeReuse/ActiveRecord
return unless job
pipeline = job.pipeline
......@@ -25,7 +24,6 @@ class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
Gitlab::EtagCaching::Store.new.touch(project_job_path(project, job))
ExpirePipelineCacheWorker.perform_async(pipeline.id)
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -17,13 +17,11 @@ class ExpirePipelineCacheWorker
# Uncomment once https://gitlab.com/gitlab-org/gitlab/-/issues/325291 is resolved
# idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
pipeline = Ci::Pipeline.find_by_id(pipeline_id)
return unless pipeline
Ci::ExpirePipelineCacheService.new.execute(pipeline)
end
# rubocop: enable CodeReuse/ActiveRecord
end
# rubocop:enable Scalability/IdempotentWorker
......@@ -16,7 +16,7 @@ module Gitlab
attr_reader :project
def perform(project_id)
@project = Project.find_by(id: project_id) # rubocop: disable CodeReuse/ActiveRecord
@project = Project.find_by_id(project_id)
return unless start_import
......
......@@ -16,12 +16,11 @@ module HashedStorage
attr_reader :project_id
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, old_disk_path = nil)
@project_id = project_id # we need to set this in order to create the lease_key
try_obtain_lease do
project = Project.without_deleted.find_by(id: project_id)
project = Project.without_deleted.find_by_id(project_id)
break unless project && project.storage_upgradable?
old_disk_path ||= Storage::LegacyProject.new(project).disk_path
......@@ -29,6 +28,5 @@ module HashedStorage
::Projects::HashedStorage::MigrationService.new(project, old_disk_path, logger: logger).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -16,12 +16,11 @@ module HashedStorage
attr_reader :project_id
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, old_disk_path = nil)
@project_id = project_id # we need to set this in order to create the lease_key
try_obtain_lease do
project = Project.without_deleted.find_by(id: project_id)
project = Project.without_deleted.find_by_id(project_id)
break unless project
old_disk_path ||= project.disk_path
......@@ -29,6 +28,5 @@ module HashedStorage
::Projects::HashedStorage::RollbackService.new(project, old_disk_path, logger: logger).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -10,13 +10,11 @@ class InvalidGpgSignatureUpdateWorker # rubocop:disable Scalability/IdempotentWo
feature_category :source_code_management
weight 2
# rubocop: disable CodeReuse/ActiveRecord
def perform(gpg_key_id)
gpg_key = GpgKey.find_by(id: gpg_key_id)
gpg_key = GpgKey.find_by_id(gpg_key_id)
return unless gpg_key
Gitlab::Gpg::InvalidGpgSignatureUpdater.new(gpg_key).run
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -14,14 +14,12 @@ class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker
# Keep extra parameter to preserve backwards compatibility with
# old `NewNoteWorker` jobs (can remove later)
# rubocop: disable CodeReuse/ActiveRecord
def perform(note_id, _params = {})
if note = Note.find_by(id: note_id)
if note = Note.find_by_id(note_id)
NotificationService.new.new_note(note) unless note.skip_notification?
Notes::PostProcessService.new(note).execute
else
Gitlab::AppLogger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job")
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -9,15 +9,13 @@ class PagesDomainVerificationWorker # rubocop:disable Scalability/IdempotentWork
feature_category :pages
# rubocop: disable CodeReuse/ActiveRecord
def perform(domain_id)
return if Gitlab::Database.read_only?
domain = PagesDomain.find_by(id: domain_id)
domain = PagesDomain.find_by_id(domain_id)
return unless domain
VerifyPagesDomainService.new(domain).execute
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -14,15 +14,13 @@ class PagesWorker # rubocop:disable Scalability/IdempotentWorker
send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
end
# rubocop: disable CodeReuse/ActiveRecord
def deploy(build_id)
build = Ci::Build.find_by(id: build_id)
build = Ci::Build.find_by_id(build_id)
update_contents = Projects::UpdatePagesService.new(build.project, build).execute
if update_contents[:status] == :success
Projects::UpdatePagesConfigurationService.new(build.project).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
def remove(namespace_path, project_path)
full_path = File.join(Settings.pages.path, namespace_path, project_path)
......
......@@ -10,12 +10,10 @@ class PipelineHooksWorker # rubocop:disable Scalability/IdempotentWorker
worker_resource_boundary :cpu
data_consistency :delayed
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
pipeline = Ci::Pipeline.find_by_id(pipeline_id)
return unless pipeline
Ci::Pipelines::HookService.new(pipeline).execute
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -10,14 +10,12 @@ class PipelineMetricsWorker # rubocop:disable Scalability/IdempotentWorker
urgency :high
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
update_metrics_for_active_pipeline(pipeline) if pipeline.active?
update_metrics_for_succeeded_pipeline(pipeline) if pipeline.success?
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
......@@ -29,11 +27,9 @@ class PipelineMetricsWorker # rubocop:disable Scalability/IdempotentWorker
metrics(pipeline).update_all(latest_build_started_at: pipeline.started_at, latest_build_finished_at: pipeline.finished_at, pipeline_id: pipeline.id)
end
# rubocop: disable CodeReuse/ActiveRecord
def metrics(pipeline)
MergeRequest::Metrics.where(merge_request_id: merge_requests(pipeline))
MergeRequest::Metrics.where(merge_request_id: merge_requests(pipeline)) # rubocop: disable CodeReuse/ActiveRecord
end
# rubocop: enable CodeReuse/ActiveRecord
def merge_requests(pipeline)
pipeline.merge_requests_as_head_pipeline.map(&:id)
......
......@@ -16,13 +16,11 @@ class PipelineProcessWorker
idempotent!
deduplicate :until_executing
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
Ci::ProcessPipelineService
.new(pipeline)
.execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -23,9 +23,8 @@ class ProjectCacheWorker
# refresh, if empty all columns will be refreshed
# refresh_statistics - A boolean that determines whether project statistics should
# be updated.
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, files = [], statistics = [], refresh_statistics = true)
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return unless project
......@@ -37,7 +36,6 @@ class ProjectCacheWorker
project.cleanup
end
# rubocop: enable CodeReuse/ActiveRecord
# NOTE: triggering both an immediate update and one in 15 minutes if we
# successfully obtain the lease. That way, we only need to wait for the
......
......@@ -13,13 +13,11 @@ class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWor
LEASE_TIMEOUT = 4.hours.to_i
# rubocop: disable CodeReuse/ActiveRecord
def perform(template_id)
return unless try_obtain_lease_for(template_id)
Admin::PropagateServiceTemplate.propagate(Integration.find_by(id: template_id))
Admin::PropagateServiceTemplate.propagate(Integration.find_by_id(template_id))
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -11,16 +11,14 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
queue_namespace :pipeline_creation
feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord
def perform(schedule_id, user_id)
schedule = Ci::PipelineSchedule.find_by(id: schedule_id)
user = User.find_by(id: user_id)
schedule = Ci::PipelineSchedule.find_by_id(schedule_id)
user = User.find_by_id(user_id)
return unless schedule && user
run_pipeline_schedule(schedule, user)
end
# rubocop: enable CodeReuse/ActiveRecord
def run_pipeline_schedule(schedule, user)
Ci::CreatePipelineService.new(schedule.project,
......
......@@ -13,17 +13,15 @@ class UpdateHighestRoleWorker
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(user_id)
user = User.find_by(id: user_id)
user = User.find_by_id(user_id)
return unless user.present?
if user.active? && user.human? && !user.internal?
Users::UpdateHighestMemberRoleService.new(user).execute
else
UserHighestRole.where(user_id: user_id).delete_all
UserHighestRole.where(user_id: user_id).delete_all # rubocop: disable CodeReuse/ActiveRecord
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -13,15 +13,13 @@ class UpdateMergeRequestsWorker # rubocop:disable Scalability/IdempotentWorker
weight 3
loggable_arguments 2, 3, 4
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, oldrev, newrev, ref)
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return unless project
user = User.find_by(id: user_id)
user = User.find_by_id(user_id)
return unless user
MergeRequests::RefreshService.new(project: project, current_user: user).execute(oldrev, newrev, ref)
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -13,11 +13,9 @@ class UpdateProjectStatisticsWorker # rubocop:disable Scalability/IdempotentWork
# project_id - The ID of the project for which to flush the cache.
# statistics - An Array containing columns from ProjectStatistics to
# refresh, if empty all columns will be refreshed
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, statistics = [])
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
Projects::UpdateStatisticsService.new(project, nil, statistics: statistics).execute
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -12,9 +12,8 @@ module Analytics
MODEL_KLASSES = %w[Issue MergeRequest].freeze
# rubocop: disable CodeReuse/ActiveRecord
def perform(group_id, model_klass = MODEL_KLASSES.first, cursor = {}, updated_at_before = Time.current)
group = Group.find_by(id: group_id)
group = Group.find_by_id(group_id)
return unless group
model = model_klass.safe_constantize
......@@ -51,7 +50,6 @@ module Analytics
true
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
......@@ -18,14 +18,12 @@ module EE
# Geo should only update Redis based cache, as data store in the database
# will be updated on primary and replicated to the secondaries.
# rubocop: disable CodeReuse/ActiveRecord
def perform_geo_secondary(project_id, refresh = [], _statistics = [])
project = ::Project.find_by(id: project_id)
project = ::Project.find_by_id(project_id)
return unless project && project.repository.exists?
project.repository.refresh_method_caches(refresh.map(&:to_sym))
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -16,18 +16,16 @@ module Geo
attr_reader :project
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id)
return unless Gitlab::Geo.primary?
@project = Project.find_by(id: project_id)
@project = Project.find_by_id(project_id)
return if project.nil? || project.pending_delete?
try_obtain_lease do
Geo::RepositoryVerificationPrimaryService.new(project).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -20,11 +20,10 @@ module Geo
delegate :project, to: :registry
# rubocop: disable CodeReuse/ActiveRecord
def perform(registry_id)
return unless Gitlab::Geo.secondary?
@registry = Geo::ProjectRegistry.find_by(id: registry_id)
@registry = Geo::ProjectRegistry.find_by_id(registry_id)
return if registry.nil? || project.nil? || project.pending_delete?
try_obtain_lease do
......@@ -32,7 +31,6 @@ module Geo
verify_checksum(:wiki)
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
......
......@@ -12,15 +12,13 @@ class MergeRequestResetApprovalsWorker # rubocop:disable Scalability/IdempotentW
worker_resource_boundary :cpu
loggable_arguments 2, 3
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, ref, newrev)
project = Project.find_by(id: project_id)
project = Project.find_by_id(project_id)
return unless project
user = User.find_by(id: user_id)
user = User.find_by_id(user_id)
return unless user
MergeRequests::ResetApprovalsService.new(project: project, current_user: user).execute(ref, newrev)
end
# rubocop: enable CodeReuse/ActiveRecord
end
......@@ -12,11 +12,10 @@ module Security
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
return if Feature.disabled?(:security_auto_fix)
::Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
::Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
project = pipeline.project
break unless project.security_setting.auto_fix_enabled?
......@@ -24,6 +23,5 @@ module Security
Security::AutoFixService.new(project, pipeline).execute
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
......@@ -12,9 +12,8 @@ module Security
feature_category :vulnerability_management
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
::Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
::Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
break unless pipeline.can_store_security_reports?
record_onboarding_progress(pipeline)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment