diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-08-01 15:38:45 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-08-07 16:57:56 +0300 |
commit | 9ef3c431e4859e1bc03267735b956d5920d5dd42 (patch) | |
tree | 5a4063641e79766c249924f5095e6c328a279846 /app/services | |
parent | faa2a123911eaf84bb57163ea7af759d4632601b (diff) |
Move some after_create parts to worker to improve performance
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issuable_base_service.rb | 1 | ||||
-rw-r--r-- | app/services/issues/create_service.rb | 7 | ||||
-rw-r--r-- | app/services/merge_requests/create_service.rb | 8 |
3 files changed, 12 insertions, 4 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index ea497729115..0e25c555136 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -182,7 +182,6 @@ class IssuableBaseService < BaseService if params.present? && create_issuable(issuable, params, label_ids: label_ids) after_create(issuable) - issuable.create_cross_references!(current_user) execute_hooks(issuable) invalidate_cache_counts(issuable, users: issuable.assignees) end diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 718a7ac1f22..9114f0ccc81 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -15,11 +15,14 @@ module Issues def before_create(issue) spam_check(issue, current_user) issue.move_to_end + + user = current_user + issue.run_after_commit do + NewIssueWorker.perform_async(issue.id, user.id) + end end def after_create(issuable) - event_service.open_issue(issuable, current_user) - notification_service.new_issue(issuable, current_user) todo_service.new_issue(issuable, current_user) user_agent_detail_service.create resolve_discussions_with_issue(issuable) diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index 19189e64acf..eb04048b748 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -17,9 +17,15 @@ module MergeRequests create(merge_request) end + def before_create(merge_request) + user = current_user + merge_request.run_after_commit do + NewMergeRequestWorker.perform_async(merge_request.id, user.id) + end + end + def after_create(issuable) event_service.open_mr(issuable, current_user) - notification_service.new_merge_request(issuable, current_user) todo_service.new_merge_request(issuable, current_user) issuable.cache_merge_request_closes_issues!(current_user) end |