app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb in maestrano-connector-rails-2.2.1 vs app/jobs/maestrano/connector/rails/concerns/synchronization_job.rb in maestrano-connector-rails-2.3.0

- old
+ new

@@ -11,17 +11,27 @@ end def find_job(organization_id) queue = Sidekiq::Queue.new(:default) queue.find do |job| - organization_id == job.item['args'][0]['arguments'].first + job_organization_id = begin + job.item['args'][0]['arguments'].first + rescue + false + end + organization_id == job_organization_id end end def find_running_job(organization_id) Sidekiq::Workers.new.find do |_, _, work| - work['queue'] == 'default' && work['payload']['args'][0]['arguments'].first == organization_id + job_organization_id = begin + work['payload']['args'][0]['arguments'].first + rescue + false + end + work['queue'] == 'default' && organization_id == job_organization_id end rescue nil end end @@ -85,10 +95,10 @@ end Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Finished synchronization, organization=#{organization.uid}, status=success") current_synchronization.mark_as_success rescue => e - Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Finished synchronization, organization=#{organization.uid}, status=error, message=#{e.message} backtrace=#{e.backtrace.join("\n\t")}") + Maestrano::Connector::Rails::ConnectorLogger.log('warn', organization, "Finished synchronization, organization=#{organization.uid}, status=error, message=\"#{e.message}\" backtrace=\"#{e.backtrace}\"") current_synchronization.mark_as_error(e.message) end end def sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts)