diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-10-07 15:20:57 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-11-07 13:11:44 +0100 |
commit | 509910b89f636f95d2d5a9cd3f38ce8f7f4f47a6 (patch) | |
tree | b9f9c147a983aa6505d0d6a9a7e4a37f26a19161 /app/services/issues/close_service.rb | |
parent | f694f94c491452a50035c2ff43c8ba595c0e73aa (diff) | |
download | gitlab-ce-509910b89f636f95d2d5a9cd3f38ce8f7f4f47a6.tar.gz |
Process commits in a separate workerprocess-commits-using-sidekiq
This moves the code used for processing commits from GitPushService to
its own Sidekiq worker: ProcessCommitWorker.
Using a Sidekiq worker allows us to process multiple commits in
parallel. This in turn will lead to issues being closed faster and cross
references being created faster. Furthermore by isolating this code into
a separate class it's easier to test and maintain the code.
The new worker also ensures it can efficiently check which issues can be
closed, without having to run numerous SQL queries for every issue.
Diffstat (limited to 'app/services/issues/close_service.rb')
-rw-r--r-- | app/services/issues/close_service.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb index 45cca216ccc..ab4c51386a4 100644 --- a/app/services/issues/close_service.rb +++ b/app/services/issues/close_service.rb @@ -1,8 +1,21 @@ module Issues class CloseService < Issues::BaseService + # Closes the supplied issue if the current user is able to do so. def execute(issue, commit: nil, notifications: true, system_note: true) return issue unless can?(current_user, :update_issue, issue) + close_issue(issue, + commit: commit, + notifications: notifications, + system_note: system_note) + end + + # Closes the supplied issue without checking if the user is authorized to + # do so. + # + # The code calling this method is responsible for ensuring that a user is + # allowed to close the given issue. + def close_issue(issue, commit: nil, notifications: true, system_note: true) if project.jira_tracker? && project.jira_service.active project.jira_service.execute(commit, issue) todo_service.close_issue(issue, current_user) |