Corrected with rubocop cop 'Style/MultilineOperationIndentation'.
This commit is contained in:
parent
834ad2d64a
commit
39578cea49
13 changed files with 48 additions and 45 deletions
|
@ -99,12 +99,12 @@ return all activity entries of an user
|
||||||
return [] if role_ids.include?(customer_role.id)
|
return [] if role_ids.include?(customer_role.id)
|
||||||
if group_ids.empty?
|
if group_ids.empty?
|
||||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
|
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
|
||||||
.order( 'created_at DESC, id DESC' )
|
.order( 'created_at DESC, id DESC' )
|
||||||
.limit( limit )
|
.limit( limit )
|
||||||
else
|
else
|
||||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
|
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
|
||||||
.order( 'created_at DESC, id DESC' )
|
.order( 'created_at DESC, id DESC' )
|
||||||
.limit( limit )
|
.limit( limit )
|
||||||
end
|
end
|
||||||
list = []
|
list = []
|
||||||
stream.each do |item|
|
stream.each do |item|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Channel::EmailParser
|
||||||
data[:from_local] = Mail::Address.new( from ).local
|
data[:from_local] = Mail::Address.new( from ).local
|
||||||
data[:from_domain] = Mail::Address.new( from ).domain
|
data[:from_domain] = Mail::Address.new( from ).domain
|
||||||
data[:from_display_name] = Mail::Address.new( from ).display_name ||
|
data[:from_display_name] = Mail::Address.new( from ).display_name ||
|
||||||
( Mail::Address.new( from ).comments && Mail::Address.new( from ).comments[0] )
|
( Mail::Address.new( from ).comments && Mail::Address.new( from ).comments[0] )
|
||||||
rescue
|
rescue
|
||||||
data[:from_email] = from
|
data[:from_email] = from
|
||||||
data[:from_local] = from
|
data[:from_local] = from
|
||||||
|
|
|
@ -151,8 +151,8 @@ returns
|
||||||
if !related_history_object
|
if !related_history_object
|
||||||
history_object = self.object_lookup( requested_object )
|
history_object = self.object_lookup( requested_object )
|
||||||
history = History.where( history_object_id: history_object.id )
|
history = History.where( history_object_id: history_object.id )
|
||||||
.where( o_id: requested_object_id )
|
.where( o_id: requested_object_id )
|
||||||
.order('created_at ASC, id ASC')
|
.order('created_at ASC, id ASC')
|
||||||
else
|
else
|
||||||
history_object_requested = self.object_lookup( requested_object )
|
history_object_requested = self.object_lookup( requested_object )
|
||||||
history_object_related = self.object_lookup( related_history_object )
|
history_object_related = self.object_lookup( related_history_object )
|
||||||
|
|
|
@ -43,8 +43,8 @@ class Job < ApplicationModel
|
||||||
|
|
||||||
# find tickets to change
|
# find tickets to change
|
||||||
tickets = Ticket.where( job.condition.permit! )
|
tickets = Ticket.where( job.condition.permit! )
|
||||||
.order( '`tickets`.`created_at` DESC' )
|
.order( '`tickets`.`created_at` DESC' )
|
||||||
.limit( 1_000 )
|
.limit( 1_000 )
|
||||||
job.processed = tickets.count
|
job.processed = tickets.count
|
||||||
tickets.each do |ticket|
|
tickets.each do |ticket|
|
||||||
#puts "CHANGE #{job.execute.inspect}"
|
#puts "CHANGE #{job.execute.inspect}"
|
||||||
|
|
|
@ -18,8 +18,10 @@ class Observer::Ticket::LastContact < ActiveRecord::Observer
|
||||||
|
|
||||||
# check if last communication is done by agent, else do not set last_contact_customer
|
# check if last communication is done by agent, else do not set last_contact_customer
|
||||||
if record.ticket.last_contact_customer == nil ||
|
if record.ticket.last_contact_customer == nil ||
|
||||||
record.ticket.last_contact_agent == nil ||
|
record.ticket.last_contact_agent == nil ||
|
||||||
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
|
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
|
||||||
|
|
||||||
|
# set last_contact customer
|
||||||
record.ticket.last_contact_customer = record.created_at
|
record.ticket.last_contact_customer = record.created_at
|
||||||
|
|
||||||
# set last_contact
|
# set last_contact
|
||||||
|
|
|
@ -88,8 +88,8 @@ return all online notifications of an user
|
||||||
def self.list(user, limit)
|
def self.list(user, limit)
|
||||||
|
|
||||||
notifications = OnlineNotification.where(user_id: user.id)
|
notifications = OnlineNotification.where(user_id: user.id)
|
||||||
.order( 'created_at DESC, id DESC' )
|
.order( 'created_at DESC, id DESC' )
|
||||||
.limit( limit )
|
.limit( limit )
|
||||||
list = []
|
list = []
|
||||||
notifications.each do |item|
|
notifications.each do |item|
|
||||||
data = item.attributes
|
data = item.attributes
|
||||||
|
@ -116,8 +116,9 @@ return all online notifications of an object
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
)
|
)
|
||||||
.order( 'created_at DESC, id DESC' )
|
.order( 'created_at DESC, id DESC' )
|
||||||
.limit( 10_000 )
|
.limit( 10_000 )
|
||||||
|
|
||||||
list = []
|
list = []
|
||||||
notifications.each do |item|
|
notifications.each do |item|
|
||||||
data = item.attributes
|
data = item.attributes
|
||||||
|
|
|
@ -38,12 +38,12 @@ class RecentView < ApplicationModel
|
||||||
def self.list( user, limit = 10, type = nil )
|
def self.list( user, limit = 10, type = nil )
|
||||||
if !type
|
if !type
|
||||||
recent_views = RecentView.where( created_by_id: user.id )
|
recent_views = RecentView.where( created_by_id: user.id )
|
||||||
.order('created_at DESC, id DESC')
|
.order('created_at DESC, id DESC')
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
else
|
else
|
||||||
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) )
|
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) )
|
||||||
.order('created_at DESC, id DESC')
|
.order('created_at DESC, id DESC')
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
list = []
|
list = []
|
||||||
|
|
|
@ -81,7 +81,7 @@ returns
|
||||||
# search
|
# search
|
||||||
store_object_id = Store::Object.lookup( name: data[:object] )
|
store_object_id = Store::Object.lookup( name: data[:object] )
|
||||||
stores = Store.where( store_object_id: store_object_id, o_id: data[:o_id].to_i )
|
stores = Store.where( store_object_id: store_object_id, o_id: data[:o_id].to_i )
|
||||||
.order('created_at ASC, id ASC')
|
.order('created_at ASC, id ASC')
|
||||||
stores
|
stores
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ returns
|
||||||
# search
|
# search
|
||||||
store_object_id = Store::Object.lookup( name: data[:object] )
|
store_object_id = Store::Object.lookup( name: data[:object] )
|
||||||
stores = Store.where( store_object_id: store_object_id )
|
stores = Store.where( store_object_id: store_object_id )
|
||||||
.where( o_id: data[:o_id] )
|
.where( o_id: data[:o_id] )
|
||||||
.order('created_at ASC, id ASC')
|
.order('created_at ASC, id ASC')
|
||||||
stores.each do |store|
|
stores.each do |store|
|
||||||
|
|
||||||
# check backend for references
|
# check backend for references
|
||||||
|
|
|
@ -95,9 +95,9 @@ returns
|
||||||
access_condition = []
|
access_condition = []
|
||||||
if user.is_role(Z_ROLENAME_AGENT)
|
if user.is_role(Z_ROLENAME_AGENT)
|
||||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||||
.where( 'groups_users.user_id = ?', user.id )
|
.where( 'groups_users.user_id = ?', user.id )
|
||||||
.where( 'groups.active = ?', true )
|
.where( 'groups.active = ?', true )
|
||||||
.map( &:id )
|
.map( &:id )
|
||||||
access_condition = [ 'group_id IN (?)', group_ids ]
|
access_condition = [ 'group_id IN (?)', group_ids ]
|
||||||
else
|
else
|
||||||
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
|
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
|
||||||
|
|
|
@ -109,13 +109,13 @@ returns
|
||||||
# get only tickets with permissions
|
# get only tickets with permissions
|
||||||
if data[:current_user].is_role('Customer')
|
if data[:current_user].is_role('Customer')
|
||||||
group_ids = Group.select( 'groups.id' )
|
group_ids = Group.select( 'groups.id' )
|
||||||
.where( 'groups.active = ?', true )
|
.where( 'groups.active = ?', true )
|
||||||
.map( &:id )
|
.map( &:id )
|
||||||
else
|
else
|
||||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||||
.where( 'groups_users.user_id = ?', [ data[:current_user].id ] )
|
.where( 'groups_users.user_id = ?', [ data[:current_user].id ] )
|
||||||
.where( 'groups.active = ?', true )
|
.where( 'groups.active = ?', true )
|
||||||
.map( &:id )
|
.map( &:id )
|
||||||
end
|
end
|
||||||
|
|
||||||
# overview meta for navbar
|
# overview meta for navbar
|
||||||
|
@ -148,10 +148,10 @@ returns
|
||||||
order_by = overview_selected.group_by + '_id, ' + order_by
|
order_by = overview_selected.group_by + '_id, ' + order_by
|
||||||
end
|
end
|
||||||
tickets = Ticket.select( 'id' )
|
tickets = Ticket.select( 'id' )
|
||||||
.where( group_id: group_ids )
|
.where( group_id: group_ids )
|
||||||
.where( _condition( overview_selected.condition ) )
|
.where( _condition( overview_selected.condition ) )
|
||||||
.order( order_by )
|
.order( order_by )
|
||||||
.limit( 500 )
|
.limit( 500 )
|
||||||
|
|
||||||
ticket_ids = []
|
ticket_ids = []
|
||||||
tickets.each { |ticket|
|
tickets.each { |ticket|
|
||||||
|
@ -159,8 +159,8 @@ returns
|
||||||
}
|
}
|
||||||
|
|
||||||
tickets_count = Ticket.where( group_id: group_ids )
|
tickets_count = Ticket.where( group_id: group_ids )
|
||||||
.where( _condition( overview_selected.condition ) )
|
.where( _condition( overview_selected.condition ) )
|
||||||
.count()
|
.count()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ticket_ids: ticket_ids,
|
ticket_ids: ticket_ids,
|
||||||
|
@ -172,14 +172,14 @@ returns
|
||||||
# get tickets for overview
|
# get tickets for overview
|
||||||
data[:start_page] ||= 1
|
data[:start_page] ||= 1
|
||||||
tickets = Ticket.where( group_id: group_ids )
|
tickets = Ticket.where( group_id: group_ids )
|
||||||
.where( _condition( overview_selected.condition ) )
|
.where( _condition( overview_selected.condition ) )
|
||||||
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )
|
||||||
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
|
# .limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] )
|
||||||
# offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
|
# .offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
|
||||||
|
|
||||||
tickets_count = Ticket.where( group_id: group_ids )
|
tickets_count = Ticket.where( group_id: group_ids )
|
||||||
.where( _condition( overview_selected.condition ) )
|
.where( _condition( overview_selected.condition ) )
|
||||||
.count()
|
.count()
|
||||||
|
|
||||||
{
|
{
|
||||||
tickets: tickets,
|
tickets: tickets,
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Token < ActiveRecord::Base
|
||||||
|
|
||||||
# check if token is still valid
|
# check if token is still valid
|
||||||
if !token.persistent &&
|
if !token.persistent &&
|
||||||
token.created_at < 1.day.ago
|
token.created_at < 1.day.ago
|
||||||
|
|
||||||
# delete token
|
# delete token
|
||||||
token.delete
|
token.delete
|
||||||
|
|
|
@ -352,7 +352,7 @@ module Import::OTRS
|
||||||
if !user
|
if !user
|
||||||
begin
|
begin
|
||||||
display_name = Mail::Address.new( article_new[:from] ).display_name ||
|
display_name = Mail::Address.new( article_new[:from] ).display_name ||
|
||||||
( Mail::Address.new( article_new[:from] ).comments && Mail::Address.new( article_new[:from] ).comments[0] )
|
( Mail::Address.new( article_new[:from] ).comments && Mail::Address.new( article_new[:from] ).comments[0] )
|
||||||
rescue
|
rescue
|
||||||
display_name = article_new[:from]
|
display_name = article_new[:from]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1296,7 +1296,7 @@ module Import::OTRS2
|
||||||
|
|
||||||
# unlock user
|
# unlock user
|
||||||
locks[:User][ email ] = false
|
locks[:User][ email ] = false
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue