Added some syntactic suguar (used in rubocop cops).
This commit is contained in:
parent
b229d024f5
commit
00cffad79e
13 changed files with 21 additions and 21 deletions
|
@ -89,7 +89,7 @@ class LongPollingController < ApplicationController
|
||||||
sleep 0.25
|
sleep 0.25
|
||||||
}
|
}
|
||||||
#sleep 2
|
#sleep 2
|
||||||
if count == 0
|
if count.zero?
|
||||||
render json: { event: 'pong' }
|
render json: { event: 'pong' }
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -442,7 +442,7 @@ returns
|
||||||
# do lookup with == to handle case insensitive databases
|
# do lookup with == to handle case insensitive databases
|
||||||
records = where(login: data[:login])
|
records = where(login: data[:login])
|
||||||
records.each {|loop_record|
|
records.each {|loop_record|
|
||||||
if loop_record.login.casecmp(data[:login]) == 0
|
if loop_record.login.casecmp(data[:login]).zero?
|
||||||
loop_record.update_attributes(data)
|
loop_record.update_attributes(data)
|
||||||
return loop_record
|
return loop_record
|
||||||
end
|
end
|
||||||
|
@ -455,7 +455,7 @@ returns
|
||||||
# do lookup with == to handle case insensitive databases
|
# do lookup with == to handle case insensitive databases
|
||||||
records = where(email: data[:email])
|
records = where(email: data[:email])
|
||||||
records.each {|loop_record|
|
records.each {|loop_record|
|
||||||
if loop_record.email.casecmp(data[:email]) == 0
|
if loop_record.email.casecmp(data[:email]).zero?
|
||||||
loop_record.update_attributes(data)
|
loop_record.update_attributes(data)
|
||||||
return loop_record
|
return loop_record
|
||||||
end
|
end
|
||||||
|
@ -468,7 +468,7 @@ returns
|
||||||
# do lookup with == to handle case insensitive databases
|
# do lookup with == to handle case insensitive databases
|
||||||
records = where(locale: data[:locale])
|
records = where(locale: data[:locale])
|
||||||
records.each {|loop_record|
|
records.each {|loop_record|
|
||||||
if loop_record.locale.casecmp(data[:locale]) == 0
|
if loop_record.locale.casecmp(data[:locale]).zero?
|
||||||
loop_record.update_attributes(data)
|
loop_record.update_attributes(data)
|
||||||
return loop_record
|
return loop_record
|
||||||
end
|
end
|
||||||
|
|
|
@ -182,7 +182,7 @@ returns
|
||||||
end
|
end
|
||||||
@imap.expunge()
|
@imap.expunge()
|
||||||
disconnect
|
disconnect
|
||||||
if count == 0
|
if count.zero?
|
||||||
Rails.logger.info ' - no message'
|
Rails.logger.info ' - no message'
|
||||||
end
|
end
|
||||||
Rails.logger.info 'done'
|
Rails.logger.info 'done'
|
||||||
|
|
|
@ -151,7 +151,7 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
disconnect
|
disconnect
|
||||||
if count == 0
|
if count.zero?
|
||||||
Rails.logger.info ' - no message'
|
Rails.logger.info ' - no message'
|
||||||
end
|
end
|
||||||
Rails.logger.info 'done'
|
Rails.logger.info 'done'
|
||||||
|
|
|
@ -193,7 +193,7 @@ class Channel::EmailParser
|
||||||
# not multipart email
|
# not multipart email
|
||||||
|
|
||||||
# text part only
|
# text part only
|
||||||
elsif !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.casecmp('text/plain') == 0
|
elsif !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.casecmp('text/plain').zero?
|
||||||
data[:body] = mail.body.decoded
|
data[:body] = mail.body.decoded
|
||||||
data[:body] = Encode.conv(mail.charset, data[:body])
|
data[:body] = Encode.conv(mail.charset, data[:body])
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class Channel::EmailParser
|
||||||
# html part only, convert to text and add it as attachment
|
# html part only, convert to text and add it as attachment
|
||||||
else
|
else
|
||||||
filename = '-no name-'
|
filename = '-no name-'
|
||||||
if mail.mime_type.to_s.casecmp('text/html') == 0
|
if mail.mime_type.to_s.casecmp('text/html').zero?
|
||||||
filename = 'message.html'
|
filename = 'message.html'
|
||||||
data[:body] = mail.body.decoded
|
data[:body] = mail.body.decoded
|
||||||
data[:body] = Encode.conv(mail.charset, data[:body])
|
data[:body] = Encode.conv(mail.charset, data[:body])
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Chat < ApplicationModel
|
||||||
|
|
||||||
# check if agents are available
|
# check if agents are available
|
||||||
available_agents = Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - 2.minutes).count
|
available_agents = Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - 2.minutes).count
|
||||||
if available_agents == 0
|
if available_agents.zero?
|
||||||
return { state: 'offline' }
|
return { state: 'offline' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Encode
|
||||||
end
|
end
|
||||||
|
|
||||||
# validate already existing utf8 strings
|
# validate already existing utf8 strings
|
||||||
if charset.casecmp('utf8') == 0 || charset.casecmp('utf-8') == 0
|
if charset.casecmp('utf8').zero? || charset.casecmp('utf-8').zero?
|
||||||
begin
|
begin
|
||||||
|
|
||||||
# return if encoding is valid
|
# return if encoding is valid
|
||||||
|
|
|
@ -635,7 +635,7 @@ module Import::Zendesk
|
||||||
|
|
||||||
zendesk_attachments = zendesk_article.attachments
|
zendesk_attachments = zendesk_article.attachments
|
||||||
|
|
||||||
next if zendesk_attachments.size == 0
|
next if zendesk_attachments.size.zero?
|
||||||
|
|
||||||
local_attachments = local_article.attachments
|
local_attachments = local_article.attachments
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ returns
|
||||||
next if !model_attributes[:attributes].include?(item)
|
next if !model_attributes[:attributes].include?(item)
|
||||||
|
|
||||||
count = model_class.where("#{item} = ?", object_id).count
|
count = model_class.where("#{item} = ?", object_id).count
|
||||||
next if count == 0
|
next if count.zero?
|
||||||
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
|
||||||
|
@ -144,7 +144,7 @@ returns
|
||||||
|
|
||||||
if reflection_value.options[:class_name] == object_name
|
if reflection_value.options[:class_name] == object_name
|
||||||
count = model_class.where("#{col_name} = ?", object_id).count
|
count = model_class.where("#{col_name} = ?", object_id).count
|
||||||
next if count == 0
|
next if count.zero?
|
||||||
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
|
||||||
|
@ -156,7 +156,7 @@ returns
|
||||||
next if reflection_value.name != object_name.downcase.to_sym
|
next if reflection_value.name != object_name.downcase.to_sym
|
||||||
|
|
||||||
count = model_class.where("#{col_name} = ?", object_id).count
|
count = model_class.where("#{col_name} = ?", object_id).count
|
||||||
next if count == 0
|
next if count.zero?
|
||||||
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
|
||||||
|
|
|
@ -242,7 +242,7 @@ class Report::Base
|
||||||
time_total = time_total + diff
|
time_total = time_total + diff
|
||||||
tickets += 1
|
tickets += 1
|
||||||
}
|
}
|
||||||
if time_total == 0 || tickets == 0
|
if time_total.zero? || tickets.zero?
|
||||||
tickets = -0.001
|
tickets = -0.001
|
||||||
else
|
else
|
||||||
tickets = time_total / tickets / 60
|
tickets = time_total / tickets / 60
|
||||||
|
@ -279,7 +279,7 @@ class Report::Base
|
||||||
time_min = diff
|
time_min = diff
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
tickets = if time_min == 0
|
tickets = if time_min.zero?
|
||||||
-0.001
|
-0.001
|
||||||
else
|
else
|
||||||
(time_min / 60).to_i
|
(time_min / 60).to_i
|
||||||
|
@ -317,7 +317,7 @@ class Report::Base
|
||||||
time_max = diff
|
time_max = diff
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
tickets = if time_max == 0
|
tickets = if time_max.zero?
|
||||||
-0.001
|
-0.001
|
||||||
else
|
else
|
||||||
(time_max / 60).to_i
|
(time_max / 60).to_i
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Stats::TicketChannelDistribution
|
||||||
channels.each {|channel|
|
channels.each {|channel|
|
||||||
count = result[channel[:sender].to_sym][:inbound]
|
count = result[channel[:sender].to_sym][:inbound]
|
||||||
#puts "#{channel.inspect}:in/#{result.inspect}:#{count}"
|
#puts "#{channel.inspect}:in/#{result.inspect}:#{count}"
|
||||||
in_process_precent = if count == 0
|
in_process_precent = if count.zero?
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
(count * 1000) / ((total_in * 1000) / 100)
|
(count * 1000) / ((total_in * 1000) / 100)
|
||||||
|
@ -75,7 +75,7 @@ class Stats::TicketChannelDistribution
|
||||||
result[channel[:sender].to_sym][:inbound_in_percent] = in_process_precent
|
result[channel[:sender].to_sym][:inbound_in_percent] = in_process_precent
|
||||||
|
|
||||||
count = result[channel[:sender].to_sym][:outbound]
|
count = result[channel[:sender].to_sym][:outbound]
|
||||||
out_process_precent = if count == 0
|
out_process_precent = if count.zero?
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
(count * 1000) / ((total_out * 1000) / 100)
|
(count * 1000) / ((total_out * 1000) / 100)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Stats::TicketEscalation
|
||||||
|
|
||||||
average = '-'
|
average = '-'
|
||||||
state = 'supergood'
|
state = 'supergood'
|
||||||
state = if own_escalated == 0
|
state = if own_escalated.zero?
|
||||||
'supergood'
|
'supergood'
|
||||||
elsif own_escalated <= 1
|
elsif own_escalated <= 1
|
||||||
'good'
|
'good'
|
||||||
|
|
|
@ -206,7 +206,7 @@ EventMachine.run {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventMachine.add_periodic_timer(0.4) {
|
EventMachine.add_periodic_timer(0.4) {
|
||||||
next if @clients.size == 0
|
next if @clients.size.zero?
|
||||||
#log 'debug', 'checking for data to send...'
|
#log 'debug', 'checking for data to send...'
|
||||||
@clients.each { |client_id, client|
|
@clients.each { |client_id, client|
|
||||||
next if client[:disconnect]
|
next if client[:disconnect]
|
||||||
|
|
Loading…
Reference in a new issue