Improved overall performance by using logger.debug { ... } instead of logger.debug(...). This decreases the LDAP import dry runtime by ~33%.
This commit is contained in:
parent
307ce2f506
commit
bf6192113a
41 changed files with 148 additions and 148 deletions
|
@ -47,7 +47,7 @@ module ApplicationController::Authenticates
|
||||||
|
|
||||||
# already logged in, early exit
|
# already logged in, early exit
|
||||||
if session.id && session[:user_id]
|
if session.id && session[:user_id]
|
||||||
logger.debug 'session based auth check'
|
logger.debug { 'session based auth check' }
|
||||||
user = User.lookup(id: session[:user_id])
|
user = User.lookup(id: session[:user_id])
|
||||||
return authentication_check_prerequesits(user, 'session', auth_param) if user
|
return authentication_check_prerequesits(user, 'session', auth_param) if user
|
||||||
end
|
end
|
||||||
|
@ -64,7 +64,7 @@ module ApplicationController::Authenticates
|
||||||
# check http basic based authentication
|
# check http basic based authentication
|
||||||
authenticate_with_http_basic do |username, password|
|
authenticate_with_http_basic do |username, password|
|
||||||
request.session_options[:skip] = true # do not send a session cookie
|
request.session_options[:skip] = true # do not send a session cookie
|
||||||
logger.debug "http basic auth check '#{username}'"
|
logger.debug { "http basic auth check '#{username}'" }
|
||||||
if Setting.get('api_password_access') == false
|
if Setting.get('api_password_access') == false
|
||||||
raise Exceptions::NotAuthorized, 'API password access disabled!'
|
raise Exceptions::NotAuthorized, 'API password access disabled!'
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ module ApplicationController::Authenticates
|
||||||
|
|
||||||
# check http token based authentication
|
# check http token based authentication
|
||||||
authenticate_with_http_token do |token_string, _options|
|
authenticate_with_http_token do |token_string, _options|
|
||||||
logger.debug "http token auth check '#{token_string}'"
|
logger.debug { "http token auth check '#{token_string}'" }
|
||||||
request.session_options[:skip] = true # do not send a session cookie
|
request.session_options[:skip] = true # do not send a session cookie
|
||||||
if Setting.get('api_token_access') == false
|
if Setting.get('api_token_access') == false
|
||||||
raise Exceptions::NotAuthorized, 'API token access disabled!'
|
raise Exceptions::NotAuthorized, 'API token access disabled!'
|
||||||
|
@ -114,7 +114,7 @@ module ApplicationController::Authenticates
|
||||||
token = Doorkeeper::OAuth::Token.from_bearer_authorization(request)
|
token = Doorkeeper::OAuth::Token.from_bearer_authorization(request)
|
||||||
if token
|
if token
|
||||||
request.session_options[:skip] = true # do not send a session cookie
|
request.session_options[:skip] = true # do not send a session cookie
|
||||||
logger.debug "oauth2 token auth check '#{token}'"
|
logger.debug { "oauth2 token auth check '#{token}'" }
|
||||||
access_token = Doorkeeper::AccessToken.by_token(token)
|
access_token = Doorkeeper::AccessToken.by_token(token)
|
||||||
|
|
||||||
if !access_token
|
if !access_token
|
||||||
|
@ -153,7 +153,7 @@ module ApplicationController::Authenticates
|
||||||
|
|
||||||
current_user_set(user, auth_type)
|
current_user_set(user, auth_type)
|
||||||
user_device_log(user, auth_type)
|
user_device_log(user, auth_type)
|
||||||
logger.debug "#{auth_type} for '#{user.login}'"
|
logger.debug { "#{auth_type} for '#{user.login}'" }
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,7 @@ class LongPollingController < ApplicationController
|
||||||
count = count - 1
|
count = count - 1
|
||||||
queue = Sessions.queue(client_id)
|
queue = Sessions.queue(client_id)
|
||||||
if queue && queue[0]
|
if queue && queue[0]
|
||||||
logger.debug "send #{queue.inspect} to #{client_id}"
|
logger.debug { "send #{queue.inspect} to #{client_id}" }
|
||||||
render json: queue
|
render json: queue
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,7 +136,7 @@ stream all accounts
|
||||||
last_channels = []
|
last_channels = []
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
logger.debug 'stream controll loop'
|
logger.debug { 'stream controll loop' }
|
||||||
|
|
||||||
current_channels = []
|
current_channels = []
|
||||||
channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account')
|
channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account')
|
||||||
|
|
|
@ -16,12 +16,12 @@ class Channel::Driver::Facebook
|
||||||
@sync = options['sync']
|
@sync = options['sync']
|
||||||
@pages = options['pages']
|
@pages = options['pages']
|
||||||
|
|
||||||
Rails.logger.debug 'facebook fetch started'
|
Rails.logger.debug { 'facebook fetch started' }
|
||||||
|
|
||||||
fetch_feed
|
fetch_feed
|
||||||
disconnect
|
disconnect
|
||||||
|
|
||||||
Rails.logger.debug 'facebook fetch completed'
|
Rails.logger.debug { 'facebook fetch completed' }
|
||||||
notice = ''
|
notice = ''
|
||||||
{
|
{
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
|
@ -104,7 +104,7 @@ returns
|
||||||
# ignore older messages
|
# ignore older messages
|
||||||
if (@channel.created_at - 15.days) > Time.zone.parse(post['created_time']) || older_import >= older_import_max
|
if (@channel.created_at - 15.days) > Time.zone.parse(post['created_time']) || older_import >= older_import_max
|
||||||
older_import += 1
|
older_import += 1
|
||||||
Rails.logger.debug "post to old: #{post['id']}/#{post['created_time']}"
|
Rails.logger.debug { "post to old: #{post['id']}/#{post['created_time']}" }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ returns
|
||||||
@sync = options[:sync]
|
@sync = options[:sync]
|
||||||
@channel = channel
|
@channel = channel
|
||||||
|
|
||||||
Rails.logger.debug 'twitter fetch started'
|
Rails.logger.debug { 'twitter fetch started' }
|
||||||
|
|
||||||
fetch_mentions
|
fetch_mentions
|
||||||
fetch_search
|
fetch_search
|
||||||
|
@ -61,7 +61,7 @@ returns
|
||||||
|
|
||||||
disconnect
|
disconnect
|
||||||
|
|
||||||
Rails.logger.debug 'twitter fetch completed'
|
Rails.logger.debug { 'twitter fetch completed' }
|
||||||
|
|
||||||
{
|
{
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
|
@ -317,7 +317,7 @@ returns
|
||||||
next if search[:term] == '#'
|
next if search[:term] == '#'
|
||||||
next if search[:group_id].blank?
|
next if search[:group_id].blank?
|
||||||
result_type = search[:type] || 'mixed'
|
result_type = search[:type] || 'mixed'
|
||||||
Rails.logger.debug " - searching for '#{search[:term]}'"
|
Rails.logger.debug { " - searching for '#{search[:term]}'" }
|
||||||
older_import = 0
|
older_import = 0
|
||||||
older_import_max = 20
|
older_import_max = 20
|
||||||
@rest_client.client.search(search[:term], result_type: result_type).collect do |tweet|
|
@rest_client.client.search(search[:term], result_type: result_type).collect do |tweet|
|
||||||
|
@ -326,7 +326,7 @@ returns
|
||||||
# ignore older messages
|
# ignore older messages
|
||||||
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
||||||
older_import += 1
|
older_import += 1
|
||||||
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
|
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ returns
|
||||||
def fetch_mentions
|
def fetch_mentions
|
||||||
return if @sync[:mentions].blank?
|
return if @sync[:mentions].blank?
|
||||||
return if @sync[:mentions][:group_id].blank?
|
return if @sync[:mentions][:group_id].blank?
|
||||||
Rails.logger.debug ' - searching for mentions'
|
Rails.logger.debug { ' - searching for mentions' }
|
||||||
older_import = 0
|
older_import = 0
|
||||||
older_import_max = 20
|
older_import_max = 20
|
||||||
@rest_client.client.mentions_timeline.each do |tweet|
|
@rest_client.client.mentions_timeline.each do |tweet|
|
||||||
|
@ -350,7 +350,7 @@ returns
|
||||||
# ignore older messages
|
# ignore older messages
|
||||||
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
||||||
older_import += 1
|
older_import += 1
|
||||||
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
|
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
next if Ticket::Article.find_by(message_id: tweet.id)
|
next if Ticket::Article.find_by(message_id: tweet.id)
|
||||||
|
@ -362,7 +362,7 @@ returns
|
||||||
def fetch_direct_messages
|
def fetch_direct_messages
|
||||||
return if @sync[:direct_messages].blank?
|
return if @sync[:direct_messages].blank?
|
||||||
return if @sync[:direct_messages][:group_id].blank?
|
return if @sync[:direct_messages][:group_id].blank?
|
||||||
Rails.logger.debug ' - searching for direct_messages'
|
Rails.logger.debug { ' - searching for direct_messages' }
|
||||||
older_import = 0
|
older_import = 0
|
||||||
older_import_max = 20
|
older_import_max = 20
|
||||||
@rest_client.client.direct_messages(full_text: 'true').each do |tweet|
|
@rest_client.client.direct_messages(full_text: 'true').each do |tweet|
|
||||||
|
@ -370,7 +370,7 @@ returns
|
||||||
# ignore older messages
|
# ignore older messages
|
||||||
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
if (@channel.created_at - 15.days) > tweet.created_at.dup.utc || older_import >= older_import_max
|
||||||
older_import += 1
|
older_import += 1
|
||||||
Rails.logger.debug "tweet to old: #{tweet.id}/#{tweet.created_at}"
|
Rails.logger.debug { "tweet to old: #{tweet.id}/#{tweet.created_at}" }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
next if Ticket::Article.find_by(message_id: tweet.id)
|
next if Ticket::Article.find_by(message_id: tweet.id)
|
||||||
|
@ -398,19 +398,19 @@ returns
|
||||||
sleep 4
|
sleep 4
|
||||||
12.times do |loop_count|
|
12.times do |loop_count|
|
||||||
if Ticket::Article.find_by(message_id: tweet.id)
|
if Ticket::Article.find_by(message_id: tweet.id)
|
||||||
Rails.logger.debug "Own tweet already imported, skipping tweet #{tweet.id}"
|
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
count = Delayed::Job.where('created_at < ?', event_time).count
|
count = Delayed::Job.where('created_at < ?', event_time).count
|
||||||
break if count.zero?
|
break if count.zero?
|
||||||
sleep_time = 2 * count
|
sleep_time = 2 * count
|
||||||
sleep_time = 5 if sleep_time > 5
|
sleep_time = 5 if sleep_time > 5
|
||||||
Rails.logger.debug "Delay importing own tweets - sleep #{sleep_time} (loop #{loop_count})"
|
Rails.logger.debug { "Delay importing own tweets - sleep #{sleep_time} (loop #{loop_count})" }
|
||||||
sleep sleep_time
|
sleep sleep_time
|
||||||
end
|
end
|
||||||
|
|
||||||
if Ticket::Article.find_by(message_id: tweet.id)
|
if Ticket::Article.find_by(message_id: tweet.id)
|
||||||
Rails.logger.debug "Own tweet already imported, skipping tweet #{tweet.id}"
|
Rails.logger.debug { "Own tweet already imported, skipping tweet #{tweet.id}" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
|
|
|
@ -349,7 +349,7 @@ class Channel::EmailParser
|
||||||
filename = $1
|
filename = $1
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
Rails.logger.debug 'Unable to get filename'
|
Rails.logger.debug { 'Unable to get filename' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ returns
|
||||||
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
|
||||||
end
|
end
|
||||||
filters.each do |key, backend|
|
filters.each do |key, backend|
|
||||||
Rails.logger.debug "run postmaster pre filter #{key}: #{backend}"
|
Rails.logger.debug { "run postmaster pre filter #{key}: #{backend}" }
|
||||||
begin
|
begin
|
||||||
backend.run(channel, mail)
|
backend.run(channel, mail)
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -684,7 +684,7 @@ returns
|
||||||
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
|
||||||
end
|
end
|
||||||
filters.each_value do |backend|
|
filters.each_value do |backend|
|
||||||
Rails.logger.debug "run postmaster post filter #{backend}"
|
Rails.logger.debug { "run postmaster post filter #{backend}" }
|
||||||
begin
|
begin
|
||||||
backend.run(channel, mail, ticket, article, session_user)
|
backend.run(channel, mail, ticket, article, session_user)
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Channel::Filter::BounceFollowUpCheck
|
||||||
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
|
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
|
||||||
next if !article
|
next if !article
|
||||||
|
|
||||||
Rails.logger.debug "Follow up for '##{article.ticket.number}' in bounce email."
|
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in bounce email." }
|
||||||
mail[ 'x-zammad-ticket-id'.to_sym ] = article.ticket_id
|
mail[ 'x-zammad-ticket-id'.to_sym ] = article.ticket_id
|
||||||
mail[ 'x-zammad-is-auto-response'.to_sym ] = true
|
mail[ 'x-zammad-is-auto-response'.to_sym ] = true
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Channel::Filter::FollowUpCheck
|
||||||
# get ticket# from subject
|
# get ticket# from subject
|
||||||
ticket = Ticket::Number.check(mail[:subject])
|
ticket = Ticket::Number.check(mail[:subject])
|
||||||
if ticket
|
if ticket
|
||||||
Rails.logger.debug "Follow up for '##{ticket.number}' in subject."
|
Rails.logger.debug { "Follow up for '##{ticket.number}' in subject." }
|
||||||
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,7 @@ module Channel::Filter::FollowUpCheck
|
||||||
if setting.include?('body')
|
if setting.include?('body')
|
||||||
ticket = Ticket::Number.check(mail[:body])
|
ticket = Ticket::Number.check(mail[:body])
|
||||||
if ticket
|
if ticket
|
||||||
Rails.logger.debug "Follow up for '##{ticket.number}' in body."
|
Rails.logger.debug { "Follow up for '##{ticket.number}' in body." }
|
||||||
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ module Channel::Filter::FollowUpCheck
|
||||||
next if !attachment[:data]
|
next if !attachment[:data]
|
||||||
ticket = Ticket::Number.check(attachment[:data])
|
ticket = Ticket::Number.check(attachment[:data])
|
||||||
next if !ticket
|
next if !ticket
|
||||||
Rails.logger.debug "Follow up for '##{ticket.number}' in attachment."
|
Rails.logger.debug { "Follow up for '##{ticket.number}' in attachment." }
|
||||||
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
mail['x-zammad-ticket-id'.to_sym] = ticket.id
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -58,7 +58,7 @@ module Channel::Filter::FollowUpCheck
|
||||||
message_id_md5 = Digest::MD5.hexdigest(message_id)
|
message_id_md5 = Digest::MD5.hexdigest(message_id)
|
||||||
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
|
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
|
||||||
next if !article
|
next if !article
|
||||||
Rails.logger.debug "Follow up for '##{article.ticket.number}' in references."
|
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in references." }
|
||||||
mail['x-zammad-ticket-id'.to_sym] = article.ticket_id
|
mail['x-zammad-ticket-id'.to_sym] = article.ticket_id
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -97,7 +97,7 @@ module Channel::Filter::FollowUpCheck
|
||||||
# if subject is different, it's no followup
|
# if subject is different, it's no followup
|
||||||
next if subject_to_check != article_first.subject
|
next if subject_to_check != article_first.subject
|
||||||
|
|
||||||
Rails.logger.debug "Follow up for '##{article.ticket.number}' in references with same subject as inital article."
|
Rails.logger.debug { "Follow up for '##{article.ticket.number}' in references with same subject as inital article." }
|
||||||
mail['x-zammad-ticket-id'.to_sym] = article_first.ticket_id
|
mail['x-zammad-ticket-id'.to_sym] = article_first.ticket_id
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,9 @@ module Channel::Filter::IdentifySender
|
||||||
if customer_user_id.present?
|
if customer_user_id.present?
|
||||||
customer_user = User.lookup(id: customer_user_id)
|
customer_user = User.lookup(id: customer_user_id)
|
||||||
if customer_user
|
if customer_user
|
||||||
Rails.logger.debug "Took customer form x-zammad-ticket-customer_id header '#{customer_user_id}'."
|
Rails.logger.debug { "Took customer form x-zammad-ticket-customer_id header '#{customer_user_id}'." }
|
||||||
else
|
else
|
||||||
Rails.logger.debug "Invalid x-zammad-ticket-customer_id header '#{customer_user_id}', no such user - take user from 'from'-header."
|
Rails.logger.debug { "Invalid x-zammad-ticket-customer_id header '#{customer_user_id}', no such user - take user from 'from'-header." }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ module Channel::Filter::IdentifySender
|
||||||
if session_user_id.present?
|
if session_user_id.present?
|
||||||
session_user = User.lookup(id: session_user_id)
|
session_user = User.lookup(id: session_user_id)
|
||||||
if session_user
|
if session_user
|
||||||
Rails.logger.debug "Took session form x-zammad-session-user-id header '#{session_user_id}'."
|
Rails.logger.debug { "Took session form x-zammad-session-user-id header '#{session_user_id}'." }
|
||||||
else
|
else
|
||||||
Rails.logger.debug "Invalid x-zammad-session-user-id header '#{session_user_id}', no such user - take user from 'from'-header."
|
Rails.logger.debug { "Invalid x-zammad-session-user-id header '#{session_user_id}', no such user - take user from 'from'-header." }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !session_user
|
if !session_user
|
||||||
|
|
|
@ -29,7 +29,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{self.class.name}.find(#{id}) notify created " + created_at.to_s
|
logger.debug { "#{self.class.name}.find(#{id}) notify created #{created_at}" }
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
PushMessages.send(
|
PushMessages.send(
|
||||||
|
@ -61,7 +61,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{self.class.name}.find(#{id}) notify UPDATED " + updated_at.to_s
|
logger.debug { "#{self.class.name}.find(#{id}) notify UPDATED #{updated_at}" }
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
PushMessages.send(
|
PushMessages.send(
|
||||||
|
@ -93,7 +93,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{self.class.name}.find(#{id}) notify TOUCH " + updated_at.to_s
|
logger.debug { "#{self.class.name}.find(#{id}) notify TOUCH #{updated_at}" }
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
PushMessages.send(
|
PushMessages.send(
|
||||||
|
@ -124,7 +124,7 @@ class OwnModel < ApplicationModel
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
logger.debug "#{self.class.name}.find(#{id}) notify DESTOY " + updated_at.to_s
|
logger.debug { "#{self.class.name}.find(#{id}) notify DESTOY #{updated_at}" }
|
||||||
class_name = self.class.name
|
class_name = self.class.name
|
||||||
class_name.gsub!(/::/, '')
|
class_name.gsub!(/::/, '')
|
||||||
PushMessages.send(
|
PushMessages.send(
|
||||||
|
|
|
@ -47,7 +47,7 @@ job.run(true)
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def run(force = false, start_at = Time.zone.now)
|
def run(force = false, start_at = Time.zone.now)
|
||||||
logger.debug "Execute job #{inspect}"
|
logger.debug { "Execute job #{inspect}" }
|
||||||
|
|
||||||
if !executable?(start_at) && force == false
|
if !executable?(start_at) && force == false
|
||||||
if next_run_at && next_run_at <= Time.zone.now
|
if next_run_at && next_run_at <= Time.zone.now
|
||||||
|
@ -72,7 +72,7 @@ job.run(true)
|
||||||
# find tickets to change
|
# find tickets to change
|
||||||
ticket_count, tickets = Ticket.selectors(condition, 2_000)
|
ticket_count, tickets = Ticket.selectors(condition, 2_000)
|
||||||
|
|
||||||
logger.debug "Job #{name} with #{ticket_count} tickets"
|
logger.debug { "Job #{name} with #{ticket_count} tickets" }
|
||||||
|
|
||||||
self.processed = ticket_count || 0
|
self.processed = ticket_count || 0
|
||||||
self.running = true
|
self.running = true
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Observer::Ticket::Article::CommunicateTelegram::BackgroundJob
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.debug "result info: #{result}"
|
Rails.logger.debug { "result info: #{result}" }
|
||||||
|
|
||||||
# only private, group messages. channel messages do not have from key
|
# only private, group messages. channel messages do not have from key
|
||||||
if result['from'] && result['chat']
|
if result['from'] && result['chat']
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Observer::Transaction < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.execute_singel_backend(backend, item, params)
|
def self.execute_singel_backend(backend, item, params)
|
||||||
Rails.logger.debug "Execute singel backend #{backend}"
|
Rails.logger.debug { "Execute singel backend #{backend}" }
|
||||||
begin
|
begin
|
||||||
UserInfo.current_user_id = nil
|
UserInfo.current_user_id = nil
|
||||||
integration = backend.new(item, params)
|
integration = backend.new(item, params)
|
||||||
|
|
|
@ -105,7 +105,7 @@ note: will not take down package migrations, use Package.unlink instead
|
||||||
if package == false
|
if package == false
|
||||||
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
|
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
|
||||||
end
|
end
|
||||||
logger.debug package.inspect
|
logger.debug { package.inspect }
|
||||||
package
|
package
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ execute all pending package migrations at once
|
||||||
if File.exist?(location)
|
if File.exist?(location)
|
||||||
content_fs = _read_file(file)
|
content_fs = _read_file(file)
|
||||||
if content_fs == data
|
if content_fs == data
|
||||||
logger.debug "NOTICE: file '#{location}' already exists, skip install"
|
logger.debug { "NOTICE: file '#{location}' already exists, skip install" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
backup_location = location + '.save'
|
backup_location = location + '.save'
|
||||||
|
|
|
@ -153,7 +153,7 @@ returns
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_permissions
|
def validate_permissions
|
||||||
Rails.logger.debug "self permission: #{self.permission_ids}"
|
Rails.logger.debug { "self permission: #{self.permission_ids}" }
|
||||||
return true if !self.permission_ids
|
return true if !self.permission_ids
|
||||||
permission_ids.each do |permission_id|
|
permission_ids.each do |permission_id|
|
||||||
permission = Permission.lookup(id: permission_id)
|
permission = Permission.lookup(id: permission_id)
|
||||||
|
|
|
@ -301,7 +301,7 @@ class Scheduler < ApplicationModel
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
realtime = Benchmark.realtime do
|
realtime = Benchmark.realtime do
|
||||||
logger.debug "*** worker thread, #{Delayed::Job.all.count} in queue"
|
logger.debug { "*** worker thread, #{Delayed::Job.all.count} in queue" }
|
||||||
result = Delayed::Worker.new.work_off
|
result = Delayed::Worker.new.work_off
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ class Scheduler < ApplicationModel
|
||||||
|
|
||||||
if count.zero?
|
if count.zero?
|
||||||
sleep wait
|
sleep wait
|
||||||
logger.debug '*** worker thread loop'
|
logger.debug { '*** worker thread loop' }
|
||||||
else
|
else
|
||||||
format "*** #{count} jobs processed at %.4f j/s, %d failed ...\n", count / realtime, result.last
|
format "*** #{count} jobs processed at %.4f j/s, %d failed ...\n", count / realtime, result.last
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,7 +137,7 @@ reload config settings
|
||||||
def reset_change_id
|
def reset_change_id
|
||||||
@@current[name] = state_current[:value]
|
@@current[name] = state_current[:value]
|
||||||
change_id = rand(999_999_999).to_s
|
change_id = rand(999_999_999).to_s
|
||||||
logger.debug "Setting.reset_change_id: set new cache, #{change_id}"
|
logger.debug { "Setting.reset_change_id: set new cache, #{change_id}" }
|
||||||
Cache.write('Setting::ChangeId', change_id, { expires_in: 24.hours })
|
Cache.write('Setting::ChangeId', change_id, { expires_in: 24.hours })
|
||||||
@@lookup_at = nil # rubocop:disable Style/ClassVars
|
@@lookup_at = nil # rubocop:disable Style/ClassVars
|
||||||
true
|
true
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Store::Provider::File
|
||||||
location = get_location(sha)
|
location = get_location(sha)
|
||||||
permission = '600'
|
permission = '600'
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
Rails.logger.debug "storge write '#{location}' (#{permission})"
|
Rails.logger.debug { "storge write '#{location}' (#{permission})" }
|
||||||
file = File.new(location, 'wb')
|
file = File.new(location, 'wb')
|
||||||
file.write(data)
|
file.write(data)
|
||||||
file.close
|
file.close
|
||||||
|
@ -27,7 +27,7 @@ class Store::Provider::File
|
||||||
# read file from fs
|
# read file from fs
|
||||||
def self.get(sha)
|
def self.get(sha)
|
||||||
location = get_location(sha)
|
location = get_location(sha)
|
||||||
Rails.logger.debug "read from fs #{location}"
|
Rails.logger.debug { "read from fs #{location}" }
|
||||||
if !File.exist?(location)
|
if !File.exist?(location)
|
||||||
raise "ERROR: No such file #{location}"
|
raise "ERROR: No such file #{location}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -805,7 +805,7 @@ perform changes on ticket
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def perform_changes(perform, perform_origin, item = nil, current_user_id = nil)
|
def perform_changes(perform, perform_origin, item = nil, current_user_id = nil)
|
||||||
logger.debug "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})"
|
logger.debug { "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})" }
|
||||||
|
|
||||||
# if the configuration contains the deletion of the ticket then
|
# if the configuration contains the deletion of the ticket then
|
||||||
# we skip all other ticket changes because they does not matter
|
# we skip all other ticket changes because they does not matter
|
||||||
|
@ -1065,7 +1065,7 @@ perform changes on ticket
|
||||||
changed = true
|
changed = true
|
||||||
|
|
||||||
self[attribute] = value['value']
|
self[attribute] = value['value']
|
||||||
logger.debug "set #{object_name}.#{attribute} = #{value['value'].inspect}"
|
logger.debug { "set #{object_name}.#{attribute} = #{value['value'].inspect}" }
|
||||||
end
|
end
|
||||||
return if !changed
|
return if !changed
|
||||||
save
|
save
|
||||||
|
|
|
@ -153,7 +153,7 @@ class Transaction::Notification
|
||||||
created_by_id: created_by_id,
|
created_by_id: created_by_id,
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
)
|
)
|
||||||
Rails.logger.debug "sent ticket online notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})"
|
Rails.logger.debug { "sent ticket online notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignore email channel notificaiton and empty emails
|
# ignore email channel notificaiton and empty emails
|
||||||
|
@ -207,7 +207,7 @@ class Transaction::Notification
|
||||||
main_object: ticket,
|
main_object: ticket,
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
)
|
)
|
||||||
Rails.logger.debug "sent ticket email notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})"
|
Rails.logger.debug { "sent ticket email notifiaction to agent (#{@item[:type]}/#{ticket.id}/#{user.email})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Transaction::Slack
|
||||||
if sent_value
|
if sent_value
|
||||||
value = Cache.get(cache_key)
|
value = Cache.get(cache_key)
|
||||||
if value == sent_value
|
if value == sent_value
|
||||||
Rails.logger.debug "did not send webhook, already sent (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
|
Rails.logger.debug { "did not send webhook, already sent (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
Cache.write(
|
Cache.write(
|
||||||
|
@ -159,7 +159,7 @@ class Transaction::Slack
|
||||||
logo_url = local_config['logo_url']
|
logo_url = local_config['logo_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
|
Rails.logger.debug { "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
|
||||||
|
|
||||||
notifier = Slack::Notifier.new(
|
notifier = Slack::Notifier.new(
|
||||||
local_config['webhook'],
|
local_config['webhook'],
|
||||||
|
@ -188,7 +188,7 @@ class Transaction::Slack
|
||||||
Rails.logger.error "Unable to post webhook: #{local_config['webhook']}: #{result.inspect}"
|
Rails.logger.error "Unable to post webhook: #{local_config['webhook']}: #{result.inspect}"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})"
|
Rails.logger.debug { "sent webhook (#{@item[:type]}/#{ticket.id}/#{local_config['webhook']})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -198,7 +198,7 @@ send user notification about new device or new location for device
|
||||||
def notification_send(template)
|
def notification_send(template)
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
|
|
||||||
Rails.logger.debug "Send notification (#{template}) to: #{user.email}"
|
Rails.logger.debug { "Send notification (#{template}) to: #{user.email}" }
|
||||||
|
|
||||||
NotificationFactory::Mailer.notification(
|
NotificationFactory::Mailer.notification(
|
||||||
template: template,
|
template: template,
|
||||||
|
|
|
@ -5,7 +5,7 @@ class ResetSettingsPlugin < Delayed::Plugin
|
||||||
callbacks do |lifecycle|
|
callbacks do |lifecycle|
|
||||||
lifecycle.before(:invoke_job) do |*_args|
|
lifecycle.before(:invoke_job) do |*_args|
|
||||||
|
|
||||||
Rails.logger.debug 'Resetting Settings before Job execution'
|
Rails.logger.debug { 'Resetting Settings before Job execution' }
|
||||||
|
|
||||||
# reload all settings before starting a job
|
# reload all settings before starting a job
|
||||||
# otherwise it might be that changed settings
|
# otherwise it might be that changed settings
|
||||||
|
|
|
@ -445,7 +445,7 @@ class String
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
# regexp was not possible because of some string encoding issue, use next
|
# regexp was not possible because of some string encoding issue, use next
|
||||||
Rails.logger.debug "Invalid string/charset combination with regexp #{regexp} in string"
|
Rails.logger.debug { "Invalid string/charset combination with regexp #{regexp} in string" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,15 +79,15 @@ returns on fail
|
||||||
end
|
end
|
||||||
|
|
||||||
# probe inbound
|
# probe inbound
|
||||||
Rails.logger.debug "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}"
|
Rails.logger.debug { "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}" }
|
||||||
result_inbound = EmailHelper::Probe.inbound(settings[:inbound])
|
result_inbound = EmailHelper::Probe.inbound(settings[:inbound])
|
||||||
Rails.logger.debug "INBOUND RESULT PROVIDER: #{result_inbound.inspect}"
|
Rails.logger.debug { "INBOUND RESULT PROVIDER: #{result_inbound.inspect}" }
|
||||||
next if result_inbound[:result] != 'ok'
|
next if result_inbound[:result] != 'ok'
|
||||||
|
|
||||||
# probe outbound
|
# probe outbound
|
||||||
Rails.logger.debug "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}"
|
Rails.logger.debug { "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}" }
|
||||||
result_outbound = EmailHelper::Probe.outbound(settings[:outbound], params[:email])
|
result_outbound = EmailHelper::Probe.outbound(settings[:outbound], params[:email])
|
||||||
Rails.logger.debug "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}"
|
Rails.logger.debug { "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}" }
|
||||||
next if result_outbound[:result] != 'ok'
|
next if result_outbound[:result] != 'ok'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -116,9 +116,9 @@ returns on fail
|
||||||
config[:options][:folder] = params[:folder]
|
config[:options][:folder] = params[:folder]
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.debug "INBOUND PROBE GUESS: #{config.inspect}"
|
Rails.logger.debug { "INBOUND PROBE GUESS: #{config.inspect}" }
|
||||||
result_inbound = EmailHelper::Probe.inbound(config)
|
result_inbound = EmailHelper::Probe.inbound(config)
|
||||||
Rails.logger.debug "INBOUND RESULT GUESS: #{result_inbound.inspect}"
|
Rails.logger.debug { "INBOUND RESULT GUESS: #{result_inbound.inspect}" }
|
||||||
|
|
||||||
next if result_inbound[:result] != 'ok'
|
next if result_inbound[:result] != 'ok'
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ returns on fail
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
outbound_map.each do |config|
|
outbound_map.each do |config|
|
||||||
Rails.logger.debug "OUTBOUND PROBE GUESS: #{config.inspect}"
|
Rails.logger.debug { "OUTBOUND PROBE GUESS: #{config.inspect}" }
|
||||||
result_outbound = EmailHelper::Probe.outbound(config, params[:email])
|
result_outbound = EmailHelper::Probe.outbound(config, params[:email])
|
||||||
Rails.logger.debug "OUTBOUND RESULT GUESS: #{result_outbound.inspect}"
|
Rails.logger.debug { "OUTBOUND RESULT GUESS: #{result_outbound.inspect}" }
|
||||||
|
|
||||||
next if result_outbound[:result] != 'ok'
|
next if result_outbound[:result] != 'ok'
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,8 @@ result
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_user(item)
|
def to_user(item)
|
||||||
Rails.logger.debug 'Create user from item...'
|
Rails.logger.debug { 'Create user from item...' }
|
||||||
Rails.logger.debug item.inspect
|
Rails.logger.debug { item.inspect }
|
||||||
|
|
||||||
# do item_user lookup
|
# do item_user lookup
|
||||||
item_user = user(item)
|
item_user = user(item)
|
||||||
|
@ -196,9 +196,9 @@ result
|
||||||
|
|
||||||
def to_ticket(post, group_id, channel, page)
|
def to_ticket(post, group_id, channel, page)
|
||||||
|
|
||||||
Rails.logger.debug 'Create ticket from post...'
|
Rails.logger.debug { 'Create ticket from post...' }
|
||||||
Rails.logger.debug post.inspect
|
Rails.logger.debug { post.inspect }
|
||||||
Rails.logger.debug group_id.inspect
|
Rails.logger.debug { group_id.inspect }
|
||||||
|
|
||||||
user = to_user(post)
|
user = to_user(post)
|
||||||
return if !user
|
return if !user
|
||||||
|
@ -228,9 +228,9 @@ result
|
||||||
|
|
||||||
def to_article(post, ticket, page)
|
def to_article(post, ticket, page)
|
||||||
|
|
||||||
Rails.logger.debug 'Create article from post...'
|
Rails.logger.debug { 'Create article from post...' }
|
||||||
Rails.logger.debug post.inspect
|
Rails.logger.debug { post.inspect }
|
||||||
Rails.logger.debug ticket.inspect
|
Rails.logger.debug { ticket.inspect }
|
||||||
|
|
||||||
user = to_user(post)
|
user = to_user(post)
|
||||||
return if !user
|
return if !user
|
||||||
|
@ -309,7 +309,7 @@ result
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_group(post, group_id, channel, page)
|
def to_group(post, group_id, channel, page)
|
||||||
Rails.logger.debug 'import post'
|
Rails.logger.debug { 'import post' }
|
||||||
return if !post['message']
|
return if !post['message']
|
||||||
ticket = nil
|
ticket = nil
|
||||||
|
|
||||||
|
@ -332,9 +332,9 @@ result
|
||||||
if article[:type] != 'facebook feed comment'
|
if article[:type] != 'facebook feed comment'
|
||||||
raise "Can't handle unknown facebook article type '#{article[:type]}'."
|
raise "Can't handle unknown facebook article type '#{article[:type]}'."
|
||||||
end
|
end
|
||||||
Rails.logger.debug 'Create feed comment from article...'
|
Rails.logger.debug { 'Create feed comment from article...' }
|
||||||
post = @client.put_comment(article[:in_reply_to], article[:body])
|
post = @client.put_comment(article[:in_reply_to], article[:body])
|
||||||
Rails.logger.debug post.inspect
|
Rails.logger.debug { post.inspect }
|
||||||
@client.get_object(post['id'])
|
@client.get_object(post['id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -371,8 +371,8 @@ result
|
||||||
|
|
||||||
def nested_comments(comments, in_reply_to)
|
def nested_comments(comments, in_reply_to)
|
||||||
|
|
||||||
Rails.logger.debug 'Fetching nested comments...'
|
Rails.logger.debug { 'Fetching nested comments...' }
|
||||||
Rails.logger.debug comments.inspect
|
Rails.logger.debug { comments.inspect }
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
return result if comments.blank?
|
return result if comments.blank?
|
||||||
|
|
|
@ -134,7 +134,7 @@ returns
|
||||||
if !references[model_class.to_s][item]
|
if !references[model_class.to_s][item]
|
||||||
references[model_class.to_s][item] = 0
|
references[model_class.to_s][item] = 0
|
||||||
end
|
end
|
||||||
Rails.logger.debug "FOUND (by id) #{model_class}->#{item} #{count}!"
|
Rails.logger.debug { "FOUND (by id) #{model_class}->#{item} #{count}!" }
|
||||||
references[model_class.to_s][item] += count
|
references[model_class.to_s][item] += count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -154,7 +154,7 @@ returns
|
||||||
if !references[model_class.to_s][col_name]
|
if !references[model_class.to_s][col_name]
|
||||||
references[model_class.to_s][col_name] = 0
|
references[model_class.to_s][col_name] = 0
|
||||||
end
|
end
|
||||||
Rails.logger.debug "FOUND (by ref without class) #{model_class}->#{col_name} #{count}!"
|
Rails.logger.debug { "FOUND (by ref without class) #{model_class}->#{col_name} #{count}!" }
|
||||||
references[model_class.to_s][col_name] += count
|
references[model_class.to_s][col_name] += count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ returns
|
||||||
if !references[model_class.to_s][col_name]
|
if !references[model_class.to_s][col_name]
|
||||||
references[model_class.to_s][col_name] = 0
|
references[model_class.to_s][col_name] = 0
|
||||||
end
|
end
|
||||||
Rails.logger.debug "FOUND (by ref with class) #{model_class}->#{col_name} #{count}!"
|
Rails.logger.debug { "FOUND (by ref with class) #{model_class}->#{col_name} #{count}!" }
|
||||||
references[model_class.to_s][col_name] += count
|
references[model_class.to_s][col_name] += count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -233,7 +233,7 @@ returns
|
||||||
# collect items and attributes to update
|
# collect items and attributes to update
|
||||||
items_to_update = {}
|
items_to_update = {}
|
||||||
attributes.each_key do |attribute|
|
attributes.each_key do |attribute|
|
||||||
Rails.logger.debug "#{object_name}: #{model}.#{attribute}->#{object_id_to_merge}->#{object_id_primary}"
|
Rails.logger.debug { "#{object_name}: #{model}.#{attribute}->#{object_id_to_merge}->#{object_id_primary}" }
|
||||||
model_object.where("#{attribute} = ?", object_id_to_merge).each do |item|
|
model_object.where("#{attribute} = ?", object_id_to_merge).each do |item|
|
||||||
if !items_to_update[item.id]
|
if !items_to_update[item.id]
|
||||||
items_to_update[item.id] = item
|
items_to_update[item.id] = item
|
||||||
|
|
|
@ -94,7 +94,7 @@ update processors
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
||||||
Rails.logger.debug "-d '#{data.to_json}'"
|
Rails.logger.debug { "-d '#{data.to_json}'" }
|
||||||
item.delete(:action)
|
item.delete(:action)
|
||||||
response = UserAgent.put(
|
response = UserAgent.put(
|
||||||
url,
|
url,
|
||||||
|
@ -163,7 +163,7 @@ create/update/delete index
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
||||||
Rails.logger.debug "-d '#{data[:data].to_json}'"
|
Rails.logger.debug { "-d '#{data[:data].to_json}'" }
|
||||||
|
|
||||||
response = UserAgent.put(
|
response = UserAgent.put(
|
||||||
url,
|
url,
|
||||||
|
@ -201,7 +201,7 @@ add new object to search index
|
||||||
return if url.blank?
|
return if url.blank?
|
||||||
|
|
||||||
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
||||||
Rails.logger.debug "-d '#{data.to_json}'"
|
Rails.logger.debug { "-d '#{data.to_json}'" }
|
||||||
|
|
||||||
response = UserAgent.post(
|
response = UserAgent.post(
|
||||||
url,
|
url,
|
||||||
|
@ -350,7 +350,7 @@ return search result
|
||||||
data['query']['bool']['must'].push condition
|
data['query']['bool']['must'].push condition
|
||||||
|
|
||||||
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
||||||
Rails.logger.debug " -d'#{data.to_json}'"
|
Rails.logger.debug { " -d'#{data.to_json}'" }
|
||||||
|
|
||||||
response = UserAgent.get(
|
response = UserAgent.get(
|
||||||
url,
|
url,
|
||||||
|
@ -448,7 +448,7 @@ get count of tickets and tickets which match on selector
|
||||||
data = selector2query(selectors, current_user, aggs_interval, limit)
|
data = selector2query(selectors, current_user, aggs_interval, limit)
|
||||||
|
|
||||||
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
||||||
Rails.logger.debug " -d'#{data.to_json}'"
|
Rails.logger.debug { " -d'#{data.to_json}'" }
|
||||||
|
|
||||||
response = UserAgent.get(
|
response = UserAgent.get(
|
||||||
url,
|
url,
|
||||||
|
@ -471,7 +471,7 @@ get count of tickets and tickets which match on selector
|
||||||
response: response,
|
response: response,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
Rails.logger.debug response.data.to_json
|
Rails.logger.debug { response.data.to_json }
|
||||||
|
|
||||||
if aggs_interval.blank? || aggs_interval[:interval].blank?
|
if aggs_interval.blank? || aggs_interval[:interval].blank?
|
||||||
ticket_ids = []
|
ticket_ids = []
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Sequencer
|
||||||
end
|
end
|
||||||
|
|
||||||
state.to_h.tap do |result|
|
state.to_h.tap do |result|
|
||||||
logger.debug("Returning Sequence '#{sequence.name}' result: #{result.inspect}")
|
logger.debug { "Returning Sequence '#{sequence.name}' result: #{result.inspect}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ class Sequencer
|
||||||
# @return [Object, nil]
|
# @return [Object, nil]
|
||||||
def optional(attribute)
|
def optional(attribute)
|
||||||
return get(attribute) if @attributes.known?(attribute)
|
return get(attribute) if @attributes.known?(attribute)
|
||||||
logger.debug("Access to unknown optional attribute '#{attribute}'.")
|
logger.debug { "Access to unknown optional attribute '#{attribute}'." }
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -184,13 +184,13 @@ class Sequencer
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(attribute, value)
|
def set(attribute, value)
|
||||||
logger.debug("Setting '#{attribute}' value (#{value.class.name}): #{value.inspect}")
|
logger.debug { "Setting '#{attribute}' value (#{value.class.name}): #{value.inspect}" }
|
||||||
@values[attribute] = value
|
@values[attribute] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(attribute)
|
def get(attribute)
|
||||||
value = @values[attribute]
|
value = @values[attribute]
|
||||||
logger.debug("Getting '#{attribute}' value (#{value.class.name}): #{value.inspect}")
|
logger.debug { "Getting '#{attribute}' value (#{value.class.name}): #{value.inspect}" }
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,19 +209,19 @@ class Sequencer
|
||||||
def initialize_attributes(units)
|
def initialize_attributes(units)
|
||||||
log_start_finish(:debug, 'Attributes lifespan initialization') do
|
log_start_finish(:debug, 'Attributes lifespan initialization') do
|
||||||
@attributes = Sequencer::Units::Attributes.new(units.declarations)
|
@attributes = Sequencer::Units::Attributes.new(units.declarations)
|
||||||
logger.debug("Attributes lifespan: #{@attributes.inspect}")
|
logger.debug { "Attributes lifespan: #{@attributes.inspect}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_parameters(parameters)
|
def initialize_parameters(parameters)
|
||||||
logger.debug("Initializing Sequencer::State with initial parameters: #{parameters.inspect}")
|
logger.debug { "Initializing Sequencer::State with initial parameters: #{parameters.inspect}" }
|
||||||
|
|
||||||
log_start_finish(:debug, 'Attribute value provisioning check and initialization') do
|
log_start_finish(:debug, 'Attribute value provisioning check and initialization') do
|
||||||
|
|
||||||
@attributes.each do |identifier, attribute|
|
@attributes.each do |identifier, attribute|
|
||||||
|
|
||||||
if !attribute.will_be_used?
|
if !attribute.will_be_used?
|
||||||
logger.debug("Attribute '#{identifier}' is provided by Unit(s) but never used.")
|
logger.debug { "Attribute '#{identifier}' is provided by Unit(s) but never used." }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class Sequencer
|
||||||
|
|
||||||
def initialize_expectations(expected_attributes)
|
def initialize_expectations(expected_attributes)
|
||||||
expected_attributes.each do |identifier|
|
expected_attributes.each do |identifier|
|
||||||
logger.debug("Adding attribute '#{identifier}' to the list of expected result attributes.")
|
logger.debug { "Adding attribute '#{identifier}' to the list of expected result attributes." }
|
||||||
@attributes[identifier].to = @result_index
|
@attributes[identifier].to = @result_index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -262,7 +262,7 @@ class Sequencer
|
||||||
remove = !attribute.will_be_used?
|
remove = !attribute.will_be_used?
|
||||||
remove ||= attribute.to <= @index
|
remove ||= attribute.to <= @index
|
||||||
if remove && attribute.will_be_used?
|
if remove && attribute.will_be_used?
|
||||||
logger.debug("Removing unneeded attribute '#{identifier}': #{@values[identifier].inspect}")
|
logger.debug { "Removing unneeded attribute '#{identifier}': #{@values[identifier].inspect}" }
|
||||||
end
|
end
|
||||||
remove
|
remove
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Sequencer
|
||||||
private
|
private
|
||||||
|
|
||||||
def changed?
|
def changed?
|
||||||
logger.debug("Changed instance associations: #{changes.inspect}")
|
logger.debug { "Changed instance associations: #{changes.inspect}" }
|
||||||
changes.present?
|
changes.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,17 @@ class Sequencer
|
||||||
state.provide(:associations) do
|
state.provide(:associations) do
|
||||||
associations.collect do |association|
|
associations.collect do |association|
|
||||||
|
|
||||||
logger.debug("Checking association '#{association}'")
|
logger.debug { "Checking association '#{association}'" }
|
||||||
next if !mapped.key?(association)
|
next if !mapped.key?(association)
|
||||||
|
|
||||||
# remove from the mapped values if it's an association
|
# remove from the mapped values if it's an association
|
||||||
value = mapped.delete(association)
|
value = mapped.delete(association)
|
||||||
logger.debug("Extracted association '#{association}' value '#{value.inspect}'")
|
logger.debug { "Extracted association '#{association}' value '#{value.inspect}'" }
|
||||||
|
|
||||||
# skip if we don't track them
|
# skip if we don't track them
|
||||||
next if tracked_associations.exclude?(association)
|
next if tracked_associations.exclude?(association)
|
||||||
|
|
||||||
logger.debug("Using value of association '#{association}'")
|
logger.debug { "Using value of association '#{association}'" }
|
||||||
[association, value]
|
[association, value]
|
||||||
end.compact.to_h
|
end.compact.to_h
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,9 +22,9 @@ class Sequencer
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_action?(action)
|
def skip_action?(action)
|
||||||
logger.debug("Checking if skip is necessary for action #{action.inspect}.")
|
logger.debug { "Checking if skip is necessary for action #{action.inspect}." }
|
||||||
return false if action.blank?
|
return false if action.blank?
|
||||||
logger.debug("Checking if skip is necessary for skip_actions #{skip_actions.inspect}.")
|
logger.debug { "Checking if skip is necessary for skip_actions #{skip_actions.inspect}." }
|
||||||
return false if skip_actions.blank?
|
return false if skip_actions.blank?
|
||||||
return true if skip_actions.include?(action)
|
return true if skip_actions.include?(action)
|
||||||
return true if skip_actions.include?(:any)
|
return true if skip_actions.include?(:any)
|
||||||
|
@ -39,9 +39,9 @@ class Sequencer
|
||||||
def process
|
def process
|
||||||
action = state.optional(:action)
|
action = state.optional(:action)
|
||||||
if self.class.skip_action?(action)
|
if self.class.skip_action?(action)
|
||||||
logger.debug("Skipping due to provided action #{action.inspect}.")
|
logger.debug { "Skipping due to provided action #{action.inspect}." }
|
||||||
else
|
else
|
||||||
logger.debug("Nope. Won't skip action #{action.inspect}.")
|
logger.debug { "Nope. Won't skip action #{action.inspect}." }
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Sequencer
|
||||||
|
|
||||||
def process
|
def process
|
||||||
return if !skip?
|
return if !skip?
|
||||||
logger.debug("Skipping. Blank #{attribute} found: #{attribute_value.inspect}")
|
logger.debug { "Skipping. Blank #{attribute} found: #{attribute_value.inspect}" }
|
||||||
state.provide(:action, :skipped)
|
state.provide(:action, :skipped)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Sequencer
|
||||||
|
|
||||||
def process
|
def process
|
||||||
return if !skip?
|
return if !skip?
|
||||||
logger.debug("Skipping. Missing mandatory attributes for #{attribute}: #{attribute_value.inspect}")
|
logger.debug { "Skipping. Missing mandatory attributes for #{attribute}: #{attribute_value.inspect}" }
|
||||||
state.provide(:action, :skipped)
|
state.provide(:action, :skipped)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Sequencer
|
||||||
private
|
private
|
||||||
|
|
||||||
def changed?
|
def changed?
|
||||||
logger.debug("Changed instance attributes: #{changes.inspect}")
|
logger.debug { "Changed instance attributes: #{changes.inspect}" }
|
||||||
changes.present?
|
changes.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Sequencer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug "Fetching and processing #{per_page} items (page: #{page}, offset: #{offset}) from Exchange folder '#{display_path}' (total: #{total})"
|
logger.debug { "Fetching and processing #{per_page} items (page: #{page}, offset: #{offset}) from Exchange folder '#{display_path}' (total: #{total})" }
|
||||||
|
|
||||||
folder.items(opts).each do |item|
|
folder.items(opts).each do |item|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Sequencer
|
||||||
|
|
||||||
item = parameters[:resource]
|
item = parameters[:resource]
|
||||||
|
|
||||||
logger.debug "Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}"
|
logger.debug { "Extracting attributes from Exchange item: #{item.get_all_properties!.inspect}" }
|
||||||
|
|
||||||
parameters.merge(
|
parameters.merge(
|
||||||
resource: ::Import::Exchange::ItemAttributes.extract(item),
|
resource: ::Import::Exchange::ItemAttributes.extract(item),
|
||||||
|
|
|
@ -713,7 +713,7 @@ returns
|
||||||
def self.log(level, message)
|
def self.log(level, message)
|
||||||
if defined?(Rails)
|
if defined?(Rails)
|
||||||
if level == 'debug'
|
if level == 'debug'
|
||||||
Rails.logger.debug message
|
Rails.logger.debug { message }
|
||||||
elsif level == 'notice'
|
elsif level == 'notice'
|
||||||
Rails.logger.notice message
|
Rails.logger.notice message
|
||||||
else
|
else
|
||||||
|
|
|
@ -75,6 +75,6 @@ class Sessions::Client
|
||||||
end
|
end
|
||||||
|
|
||||||
def log(msg)
|
def log(msg)
|
||||||
Rails.logger.debug "client(#{@node_id}.#{@client_id}) #{msg}"
|
Rails.logger.debug { "client(#{@node_id}.#{@client_id}) #{msg}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -226,8 +226,8 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_user(params)
|
def to_user(params)
|
||||||
Rails.logger.debug 'Create user from message...'
|
Rails.logger.debug { 'Create user from message...' }
|
||||||
Rails.logger.debug params.inspect
|
Rails.logger.debug { params.inspect }
|
||||||
|
|
||||||
# do message_user lookup
|
# do message_user lookup
|
||||||
message_user = user(params)
|
message_user = user(params)
|
||||||
|
@ -272,10 +272,10 @@ returns
|
||||||
def to_ticket(params, user, group_id, channel)
|
def to_ticket(params, user, group_id, channel)
|
||||||
UserInfo.current_user_id = user.id
|
UserInfo.current_user_id = user.id
|
||||||
|
|
||||||
Rails.logger.debug 'Create ticket from message...'
|
Rails.logger.debug { 'Create ticket from message...' }
|
||||||
Rails.logger.debug params.inspect
|
Rails.logger.debug { params.inspect }
|
||||||
Rails.logger.debug user.inspect
|
Rails.logger.debug { user.inspect }
|
||||||
Rails.logger.debug group_id.inspect
|
Rails.logger.debug { group_id.inspect }
|
||||||
|
|
||||||
# prepare title
|
# prepare title
|
||||||
title = '-'
|
title = '-'
|
||||||
|
@ -341,13 +341,13 @@ returns
|
||||||
def to_article(params, user, ticket, channel, article = nil)
|
def to_article(params, user, ticket, channel, article = nil)
|
||||||
|
|
||||||
if article
|
if article
|
||||||
Rails.logger.debug 'Update article from message...'
|
Rails.logger.debug { 'Update article from message...' }
|
||||||
else
|
else
|
||||||
Rails.logger.debug 'Create article from message...'
|
Rails.logger.debug { 'Create article from message...' }
|
||||||
end
|
end
|
||||||
Rails.logger.debug params.inspect
|
Rails.logger.debug { params.inspect }
|
||||||
Rails.logger.debug user.inspect
|
Rails.logger.debug { user.inspect }
|
||||||
Rails.logger.debug ticket.inspect
|
Rails.logger.debug { ticket.inspect }
|
||||||
|
|
||||||
UserInfo.current_user_id = user.id
|
UserInfo.current_user_id = user.id
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ returns
|
||||||
|
|
||||||
def to_group(params, group_id, channel)
|
def to_group(params, group_id, channel)
|
||||||
# begin import
|
# begin import
|
||||||
Rails.logger.debug 'import message'
|
Rails.logger.debug { 'import message' }
|
||||||
|
|
||||||
# map channel_post params to message
|
# map channel_post params to message
|
||||||
if params[:channel_post]
|
if params[:channel_post]
|
||||||
|
@ -660,12 +660,12 @@ returns
|
||||||
def from_article(article)
|
def from_article(article)
|
||||||
|
|
||||||
message = nil
|
message = nil
|
||||||
Rails.logger.debug "Create telegram personal message from article to '#{article[:to]}'..."
|
Rails.logger.debug { "Create telegram personal message from article to '#{article[:to]}'..." }
|
||||||
|
|
||||||
message = {}
|
message = {}
|
||||||
# TODO: create telegram message here
|
# TODO: create telegram message here
|
||||||
|
|
||||||
Rails.logger.debug message.inspect
|
Rails.logger.debug { message.inspect }
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@ class TweetBase
|
||||||
def user(tweet)
|
def user(tweet)
|
||||||
|
|
||||||
if tweet.class == Twitter::DirectMessage
|
if tweet.class == Twitter::DirectMessage
|
||||||
Rails.logger.debug "Twitter sender for dm (#{tweet.id}): found"
|
Rails.logger.debug { "Twitter sender for dm (#{tweet.id}): found" }
|
||||||
Rails.logger.debug tweet.sender.inspect
|
Rails.logger.debug { tweet.sender.inspect }
|
||||||
tweet.sender
|
tweet.sender
|
||||||
elsif tweet.class == Twitter::Tweet
|
elsif tweet.class == Twitter::Tweet
|
||||||
Rails.logger.debug "Twitter sender for tweet (#{tweet.id}): found"
|
Rails.logger.debug { "Twitter sender for tweet (#{tweet.id}): found" }
|
||||||
Rails.logger.debug tweet.user.inspect
|
Rails.logger.debug { tweet.user.inspect }
|
||||||
tweet.user
|
tweet.user
|
||||||
else
|
else
|
||||||
raise "Unknown tweet type '#{tweet.class}'"
|
raise "Unknown tweet type '#{tweet.class}'"
|
||||||
|
@ -25,8 +25,8 @@ class TweetBase
|
||||||
|
|
||||||
def to_user(tweet)
|
def to_user(tweet)
|
||||||
|
|
||||||
Rails.logger.debug 'Create user from tweet...'
|
Rails.logger.debug { 'Create user from tweet...' }
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug { tweet.inspect }
|
||||||
|
|
||||||
# do tweet_user lookup
|
# do tweet_user lookup
|
||||||
tweet_user = user(tweet)
|
tweet_user = user(tweet)
|
||||||
|
@ -102,10 +102,10 @@ class TweetBase
|
||||||
def to_ticket(tweet, user, group_id, channel)
|
def to_ticket(tweet, user, group_id, channel)
|
||||||
UserInfo.current_user_id = user.id
|
UserInfo.current_user_id = user.id
|
||||||
|
|
||||||
Rails.logger.debug 'Create ticket from tweet...'
|
Rails.logger.debug { 'Create ticket from tweet...' }
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug { tweet.inspect }
|
||||||
Rails.logger.debug user.inspect
|
Rails.logger.debug { user.inspect }
|
||||||
Rails.logger.debug group_id.inspect
|
Rails.logger.debug { group_id.inspect }
|
||||||
|
|
||||||
if tweet.class == Twitter::DirectMessage
|
if tweet.class == Twitter::DirectMessage
|
||||||
ticket = Ticket.find_by(
|
ticket = Ticket.find_by(
|
||||||
|
@ -143,10 +143,10 @@ class TweetBase
|
||||||
|
|
||||||
def to_article(tweet, user, ticket, channel)
|
def to_article(tweet, user, ticket, channel)
|
||||||
|
|
||||||
Rails.logger.debug 'Create article from tweet...'
|
Rails.logger.debug { 'Create article from tweet...' }
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug { tweet.inspect }
|
||||||
Rails.logger.debug user.inspect
|
Rails.logger.debug { user.inspect }
|
||||||
Rails.logger.debug ticket.inspect
|
Rails.logger.debug { ticket.inspect }
|
||||||
|
|
||||||
# import tweet
|
# import tweet
|
||||||
to = nil
|
to = nil
|
||||||
|
@ -233,7 +233,7 @@ class TweetBase
|
||||||
|
|
||||||
def to_group(tweet, group_id, channel)
|
def to_group(tweet, group_id, channel)
|
||||||
|
|
||||||
Rails.logger.debug 'import tweet'
|
Rails.logger.debug { 'import tweet' }
|
||||||
|
|
||||||
# use transaction
|
# use transaction
|
||||||
if @connection_type == 'stream'
|
if @connection_type == 'stream'
|
||||||
|
@ -289,7 +289,7 @@ class TweetBase
|
||||||
tweet = nil
|
tweet = nil
|
||||||
if article[:type] == 'twitter direct-message'
|
if article[:type] == 'twitter direct-message'
|
||||||
|
|
||||||
Rails.logger.debug "Create twitter direct message from article to '#{article[:to]}'..."
|
Rails.logger.debug { "Create twitter direct message from article to '#{article[:to]}'..." }
|
||||||
|
|
||||||
tweet = @client.create_direct_message(
|
tweet = @client.create_direct_message(
|
||||||
article[:to],
|
article[:to],
|
||||||
|
@ -298,7 +298,7 @@ class TweetBase
|
||||||
)
|
)
|
||||||
elsif article[:type] == 'twitter status'
|
elsif article[:type] == 'twitter status'
|
||||||
|
|
||||||
Rails.logger.debug 'Create tweet from article...'
|
Rails.logger.debug { 'Create tweet from article...' }
|
||||||
|
|
||||||
tweet = @client.update(
|
tweet = @client.update(
|
||||||
article[:body],
|
article[:body],
|
||||||
|
@ -310,7 +310,7 @@ class TweetBase
|
||||||
raise "Can't handle unknown twitter article type '#{article[:type]}'."
|
raise "Can't handle unknown twitter article type '#{article[:type]}'."
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.debug tweet.inspect
|
Rails.logger.debug { tweet.inspect }
|
||||||
tweet
|
tweet
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ class TweetBase
|
||||||
next if !local_channel.options[:user]
|
next if !local_channel.options[:user]
|
||||||
next if !local_channel.options[:user][:id]
|
next if !local_channel.options[:user][:id]
|
||||||
next if local_channel.options[:user][:id].to_s != tweet_user.id.to_s
|
next if local_channel.options[:user][:id].to_s != tweet_user.id.to_s
|
||||||
Rails.logger.debug "Tweet is sent by local account with user id #{tweet_user.id} and tweet.id #{tweet.id}"
|
Rails.logger.debug { "Tweet is sent by local account with user id #{tweet_user.id} and tweet.id #{tweet.id}" }
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue