Skip to content

Commit

Permalink
Merge pull request #600 from SimonPe/performance
Browse files Browse the repository at this point in the history
Improve performance
  • Loading branch information
n-rodriguez committed Jul 24, 2016
2 parents eee29b1 + 2c82baf commit 42ed747
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/workers/githosting_shell_worker.rb
Expand Up @@ -3,6 +3,15 @@ class GithostingShellWorker

sidekiq_options queue: :redmine_git_hosting, retry: false

def self.maybe_do(command, object, options = {})
args = [command.to_s, object, options]
Sidekiq::Queue.new(:redmine_git_hosting).each do |job|
return if job.args == args
end

perform_async(command, object, options)
end

def perform(command, object, options = {})
logger.info("#{command} | #{object} | #{options}")
RedmineGitHosting::GitoliteWrapper.resync_gitolite(command, object, options)
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_git_hosting/gitolite_accessor.rb
Expand Up @@ -140,7 +140,7 @@ def resync_gitolite(command, object, options = {})
end

if RedmineGitHosting::Config.gitolite_use_sidekiq? && !bypass
GithostingShellWorker.perform_async(command, object, options)
GithostingShellWorker.maybe_do(command, object, options)
else
GitoliteWrapper.resync_gitolite(command, object, options)
end
Expand Down
Expand Up @@ -7,8 +7,10 @@ def call
return if git_projects.empty?
admin.transaction do
git_projects.each do |project|
handle_project_update(project)
gitolite_admin_repo_commit(project.identifier)
if project.gitolite_repos.any?
handle_project_update(project)
gitolite_admin_repo_commit(project.identifier)
end
end
end
end
Expand Down

0 comments on commit 42ed747

Please sign in to comment.