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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
947c09c2
Commit
947c09c2
authored
Aug 08, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify checking if objects exist code in new issaubles workers
parent
9e7ac48b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
13 deletions
+22
-13
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+1
-0
app/services/merge_requests/create_service.rb
app/services/merge_requests/create_service.rb
+1
-0
app/workers/concerns/new_issuable.rb
app/workers/concerns/new_issuable.rb
+14
-11
app/workers/new_issue_worker.rb
app/workers/new_issue_worker.rb
+1
-1
app/workers/new_merge_request_worker.rb
app/workers/new_merge_request_worker.rb
+1
-1
changelogs/unreleased/36119-issuable-workers.yml
changelogs/unreleased/36119-issuable-workers.yml
+4
-0
No files found.
app/services/issues/create_service.rb
View file @
947c09c2
...
...
@@ -16,6 +16,7 @@ module Issues
spam_check
(
issue
,
current_user
)
issue
.
move_to_end
# current_user (defined in BaseService) is not available within run_after_commit block
user
=
current_user
issue
.
run_after_commit
do
NewIssueWorker
.
perform_async
(
issue
.
id
,
user
.
id
)
...
...
app/services/merge_requests/create_service.rb
View file @
947c09c2
...
...
@@ -17,6 +17,7 @@ module MergeRequests
end
def
before_create
(
merge_request
)
# current_user (defined in BaseService) is not available within run_after_commit block
user
=
current_user
merge_request
.
run_after_commit
do
NewMergeRequestWorker
.
perform_async
(
merge_request
.
id
,
user
.
id
)
...
...
app/workers/concerns/new_issuable.rb
View file @
947c09c2
module
NewIssuable
attr_reader
:issuable
,
:user
def
ensure_objects_found
(
issuable_id
,
user_id
)
@issuable
=
issuable_class
.
find_by
(
id:
issuable
_id
)
unless
@issuable
log_error
(
issuable_class
,
issuable_id
)
return
fals
e
end
def
objects_found?
(
issuable_id
,
user_id
)
set_user
(
user
_id
)
set_issuable
(
issuable_id
)
user
&&
issuabl
e
end
def
set_user
(
user_id
)
@user
=
User
.
find_by
(
id:
user_id
)
unless
@user
log_error
(
User
,
user_id
)
return
false
end
true
log_error
(
User
,
user_id
)
unless
@user
end
def
set_issuable
(
issuable_id
)
@issuable
=
issuable_class
.
find_by
(
id:
issuable_id
)
log_error
(
issuable_class
,
issuable_id
)
unless
@issuable
end
def
log_error
(
record_class
,
record_id
)
...
...
app/workers/new_issue_worker.rb
View file @
947c09c2
...
...
@@ -4,7 +4,7 @@ class NewIssueWorker
include
NewIssuable
def
perform
(
issue_id
,
user_id
)
return
unless
ensure_objects_found
(
issue_id
,
user_id
)
return
unless
objects_found?
(
issue_id
,
user_id
)
EventCreateService
.
new
.
open_issue
(
issuable
,
user
)
NotificationService
.
new
.
new_issue
(
issuable
,
user
)
...
...
app/workers/new_merge_request_worker.rb
View file @
947c09c2
...
...
@@ -4,7 +4,7 @@ class NewMergeRequestWorker
include
NewIssuable
def
perform
(
merge_request_id
,
user_id
)
return
unless
ensure_objects_found
(
merge_request_id
,
user_id
)
return
unless
objects_found?
(
merge_request_id
,
user_id
)
EventCreateService
.
new
.
open_mr
(
issuable
,
user
)
NotificationService
.
new
.
new_merge_request
(
issuable
,
user
)
...
...
changelogs/unreleased/36119-issuable-workers.yml
0 → 100644
View file @
947c09c2
---
title
:
Simplify checking if objects exist code in new issaubles workers
merge_request
:
author
:
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