Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f9237e2d
Commit
f9237e2d
authored
Nov 10, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CodeReuse/ActiveRecord offenses in workers
Use the allowed find_by_id method instead of find_by(id: 1).
parent
fd23cb31
Changes
42
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
53 additions
and
128 deletions
+53
-128
app/workers/authorized_projects_worker.rb
app/workers/authorized_projects_worker.rb
+1
-3
app/workers/build_hooks_worker.rb
app/workers/build_hooks_worker.rb
+1
-1
app/workers/build_queue_worker.rb
app/workers/build_queue_worker.rb
+1
-3
app/workers/build_success_worker.rb
app/workers/build_success_worker.rb
+1
-3
app/workers/chat_notification_worker.rb
app/workers/chat_notification_worker.rb
+1
-3
app/workers/ci/archive_trace_worker.rb
app/workers/ci/archive_trace_worker.rb
+1
-3
app/workers/ci/build_finished_worker.rb
app/workers/ci/build_finished_worker.rb
+1
-1
app/workers/ci/build_trace_chunk_flush_worker.rb
app/workers/ci/build_trace_chunk_flush_worker.rb
+1
-3
app/workers/cluster_update_app_worker.rb
app/workers/cluster_update_app_worker.rb
+1
-3
app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
...ers/concerns/gitlab/github_import/rescheduling_methods.rb
+1
-3
app/workers/concerns/gitlab/github_import/stage_methods.rb
app/workers/concerns/gitlab/github_import/stage_methods.rb
+3
-3
app/workers/concerns/gitlab/jira_import/import_worker.rb
app/workers/concerns/gitlab/jira_import/import_worker.rb
+1
-1
app/workers/concerns/new_issuable.rb
app/workers/concerns/new_issuable.rb
+2
-6
app/workers/create_commit_signature_worker.rb
app/workers/create_commit_signature_worker.rb
+1
-3
app/workers/delete_container_repository_worker.rb
app/workers/delete_container_repository_worker.rb
+2
-4
app/workers/detect_repository_languages_worker.rb
app/workers/detect_repository_languages_worker.rb
+1
-3
app/workers/expire_build_instance_artifacts_worker.rb
app/workers/expire_build_instance_artifacts_worker.rb
+3
-3
app/workers/expire_job_cache_worker.rb
app/workers/expire_job_cache_worker.rb
+1
-3
app/workers/expire_pipeline_cache_worker.rb
app/workers/expire_pipeline_cache_worker.rb
+1
-3
app/workers/gitlab/jira_import/stage/start_import_worker.rb
app/workers/gitlab/jira_import/stage/start_import_worker.rb
+1
-1
app/workers/hashed_storage/project_migrate_worker.rb
app/workers/hashed_storage/project_migrate_worker.rb
+1
-3
app/workers/hashed_storage/project_rollback_worker.rb
app/workers/hashed_storage/project_rollback_worker.rb
+1
-3
app/workers/invalid_gpg_signature_update_worker.rb
app/workers/invalid_gpg_signature_update_worker.rb
+1
-3
app/workers/new_note_worker.rb
app/workers/new_note_worker.rb
+1
-3
app/workers/pages_domain_verification_worker.rb
app/workers/pages_domain_verification_worker.rb
+1
-3
app/workers/pages_worker.rb
app/workers/pages_worker.rb
+1
-3
app/workers/pipeline_hooks_worker.rb
app/workers/pipeline_hooks_worker.rb
+1
-3
app/workers/pipeline_metrics_worker.rb
app/workers/pipeline_metrics_worker.rb
+2
-6
app/workers/pipeline_process_worker.rb
app/workers/pipeline_process_worker.rb
+1
-3
app/workers/project_cache_worker.rb
app/workers/project_cache_worker.rb
+1
-3
app/workers/propagate_service_template_worker.rb
app/workers/propagate_service_template_worker.rb
+1
-3
app/workers/run_pipeline_schedule_worker.rb
app/workers/run_pipeline_schedule_worker.rb
+2
-4
app/workers/update_highest_role_worker.rb
app/workers/update_highest_role_worker.rb
+2
-4
app/workers/update_merge_requests_worker.rb
app/workers/update_merge_requests_worker.rb
+2
-4
app/workers/update_project_statistics_worker.rb
app/workers/update_project_statistics_worker.rb
+1
-3
ee/app/workers/analytics/cycle_analytics/group_data_loader_worker.rb
...ers/analytics/cycle_analytics/group_data_loader_worker.rb
+1
-3
ee/app/workers/ee/project_cache_worker.rb
ee/app/workers/ee/project_cache_worker.rb
+1
-3
ee/app/workers/geo/repository_verification/primary/single_worker.rb
...kers/geo/repository_verification/primary/single_worker.rb
+1
-3
ee/app/workers/geo/repository_verification/secondary/single_worker.rb
...rs/geo/repository_verification/secondary/single_worker.rb
+1
-3
ee/app/workers/merge_request_reset_approvals_worker.rb
ee/app/workers/merge_request_reset_approvals_worker.rb
+2
-4
ee/app/workers/security/auto_fix_worker.rb
ee/app/workers/security/auto_fix_worker.rb
+1
-3
ee/app/workers/security/store_scans_worker.rb
ee/app/workers/security/store_scans_worker.rb
+1
-2
No files found.
app/workers/authorized_projects_worker.rb
View file @
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
app/workers/build_hooks_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/build_queue_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/build_success_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/chat_notification_worker.rb
View file @
f9237e2d
...
...
@@ -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
|
...
...
app/workers/ci/archive_trace_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/ci/build_finished_worker.rb
View file @
f9237e2d
...
...
@@ -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?
...
...
app/workers/ci/build_trace_chunk_flush_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/cluster_update_app_worker.rb
View file @
f9237e2d
...
...
@@ -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?
...
...
app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
View file @
f9237e2d
...
...
@@ -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
)
...
...
app/workers/concerns/gitlab/github_import/stage_methods.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/concerns/gitlab/jira_import/import_worker.rb
View file @
f9237e2d
...
...
@@ -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
)
...
...
app/workers/concerns/new_issuable.rb
View file @
f9237e2d
...
...
@@ -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"
)
...
...
app/workers/create_commit_signature_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/delete_container_repository_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/detect_repository_languages_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/expire_build_instance_artifacts_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/expire_job_cache_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/expire_pipeline_cache_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/gitlab/jira_import/stage/start_import_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/hashed_storage/project_migrate_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/hashed_storage/project_rollback_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/invalid_gpg_signature_update_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/new_note_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/pages_domain_verification_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/pages_worker.rb
View file @
f9237e2d
...
...
@@ -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
)
...
...
app/workers/pipeline_hooks_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/pipeline_metrics_worker.rb
View file @
f9237e2d
...
...
@@ -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
)
...
...
app/workers/pipeline_process_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/project_cache_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/propagate_service_template_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
app/workers/run_pipeline_schedule_worker.rb
View file @
f9237e2d
...
...
@@ -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
,
...
...
app/workers/update_highest_role_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/update_merge_requests_worker.rb
View file @
f9237e2d
...
...
@@ -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
app/workers/update_project_statistics_worker.rb
View file @
f9237e2d
...
...
@@ -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
ee/app/workers/analytics/cycle_analytics/group_data_loader_worker.rb
View file @
f9237e2d
...
...
@@ -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
ee/app/workers/ee/project_cache_worker.rb
View file @
f9237e2d
...
...
@@ -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
ee/app/workers/geo/repository_verification/primary/single_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
ee/app/workers/geo/repository_verification/secondary/single_worker.rb
View file @
f9237e2d
...
...
@@ -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
...
...
ee/app/workers/merge_request_reset_approvals_worker.rb
View file @
f9237e2d
...
...
@@ -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
ee/app/workers/security/auto_fix_worker.rb
View file @
f9237e2d
...
...
@@ -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
ee/app/workers/security/store_scans_worker.rb
View file @
f9237e2d
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment