diff options
author | James Lopez <james@jameslopez.es> | 2017-05-05 19:57:52 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-05-05 19:57:52 +0300 |
commit | 856a511b4804a0b78294a29bbba86ac111d960f8 (patch) | |
tree | a6eeba69fcfa386f8b089d9ec8bc3fc11d9ec374 /app | |
parent | f15466bd5bd2ce5390e392785d7c750c176acbec (diff) |
refactor code based on feedback
Diffstat (limited to 'app')
-rw-r--r-- | app/services/projects/propagate_service_template.rb | 12 | ||||
-rw-r--r-- | app/workers/propagate_service_template_worker.rb | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/app/services/projects/propagate_service_template.rb b/app/services/projects/propagate_service_template.rb index 2999e1af385..a8ef2108492 100644 --- a/app/services/projects/propagate_service_template.rb +++ b/app/services/projects/propagate_service_template.rb @@ -11,7 +11,7 @@ module Projects end def propagate - return unless @template&.active? + return unless @template.active? Rails.logger.info("Propagating services for template #{@template.id}") @@ -32,11 +32,11 @@ module Projects def bulk_create_from_template(batch) service_list = batch.map do |project_id| - service_hash.merge('project_id' => project_id).values + service_hash.values << project_id end Project.transaction do - bulk_insert_services(service_hash.keys + ['project_id'], service_list) + bulk_insert_services(service_hash.keys << 'project_id', service_list) run_callbacks(batch) end end @@ -75,9 +75,9 @@ module Projects template_hash.each_with_object({}) do |(key, value), service_hash| value = value.is_a?(Hash) ? value.to_json : value - key = Gitlab::Database.postgresql? ? "\"#{key}\"" : "`#{key}`" - service_hash[key] = ActiveRecord::Base.sanitize(value) + service_hash[ActiveRecord::Base.connection.quote_column_name(key)] = + ActiveRecord::Base.sanitize(value) end end end @@ -93,7 +93,7 @@ module Projects end def active_external_issue_tracker? - @template.category == :issue_tracker && !@template.default + @template.issue_tracker? && !@template.default end def active_external_wiki? diff --git a/app/workers/propagate_service_template_worker.rb b/app/workers/propagate_service_template_worker.rb index f1fc7ccb955..5ce0e0405d0 100644 --- a/app/workers/propagate_service_template_worker.rb +++ b/app/workers/propagate_service_template_worker.rb @@ -3,8 +3,6 @@ class PropagateServiceTemplateWorker include Sidekiq::Worker include DedicatedSidekiqQueue - sidekiq_options retry: 3 - LEASE_TIMEOUT = 4.hours.to_i def perform(template_id) |