Corrected with rubocop cop 'Style/DotPosition'.
This commit is contained in:
parent
329efa8566
commit
b2fd3ba9f0
9 changed files with 64 additions and 64 deletions
|
@ -98,13 +98,13 @@ return all activity entries of an user
|
|||
|
||||
return [] if role_ids.include?(customer_role.id)
|
||||
if group_ids.empty?
|
||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids ).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( limit )
|
||||
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 ).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
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' )
|
||||
.limit( limit )
|
||||
end
|
||||
list = []
|
||||
stream.each do |item|
|
||||
|
|
|
@ -150,9 +150,9 @@ returns
|
|||
def self.list( requested_object, requested_object_id, related_history_object = nil, assets = nil )
|
||||
if !related_history_object
|
||||
history_object = self.object_lookup( requested_object )
|
||||
history = History.where( history_object_id: history_object.id ).
|
||||
where( o_id: requested_object_id ).
|
||||
order('created_at ASC, id ASC')
|
||||
history = History.where( history_object_id: history_object.id )
|
||||
.where( o_id: requested_object_id )
|
||||
.order('created_at ASC, id ASC')
|
||||
else
|
||||
history_object_requested = self.object_lookup( requested_object )
|
||||
history_object_related = self.object_lookup( related_history_object )
|
||||
|
@ -162,8 +162,8 @@ returns
|
|||
requested_object_id,
|
||||
history_object_related.id,
|
||||
requested_object_id,
|
||||
).
|
||||
order('created_at ASC, id ASC')
|
||||
)
|
||||
.order('created_at ASC, id ASC')
|
||||
end
|
||||
asset_list = {}
|
||||
list = []
|
||||
|
|
|
@ -42,9 +42,9 @@ class Job < ApplicationModel
|
|||
next if !job.timeplan['minutes'].include?( match_minutes(time.min.to_s) )
|
||||
|
||||
# find tickets to change
|
||||
tickets = Ticket.where( job.condition.permit! ).
|
||||
order( '`tickets`.`created_at` DESC' ).
|
||||
limit( 1_000 )
|
||||
tickets = Ticket.where( job.condition.permit! )
|
||||
.order( '`tickets`.`created_at` DESC' )
|
||||
.limit( 1_000 )
|
||||
job.processed = tickets.count
|
||||
tickets.each do |ticket|
|
||||
#puts "CHANGE #{job.execute.inspect}"
|
||||
|
|
|
@ -87,9 +87,9 @@ return all online notifications of an user
|
|||
|
||||
def self.list(user, limit)
|
||||
|
||||
notifications = OnlineNotification.where(user_id: user.id).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
notifications = OnlineNotification.where(user_id: user.id)
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( limit )
|
||||
list = []
|
||||
notifications.each do |item|
|
||||
data = item.attributes
|
||||
|
@ -115,9 +115,9 @@ return all online notifications of an object
|
|||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( 10_000 )
|
||||
)
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( 10_000 )
|
||||
list = []
|
||||
notifications.each do |item|
|
||||
data = item.attributes
|
||||
|
|
|
@ -26,9 +26,9 @@ class RecentView < ApplicationModel
|
|||
|
||||
def self.log_destroy( requested_object, requested_object_id )
|
||||
return if requested_object == 'RecentView'
|
||||
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) ).
|
||||
where( o_id: requested_object_id ).
|
||||
destroy_all
|
||||
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) )
|
||||
.where( o_id: requested_object_id )
|
||||
.destroy_all
|
||||
end
|
||||
|
||||
def self.user_log_destroy( user )
|
||||
|
@ -37,13 +37,13 @@ class RecentView < ApplicationModel
|
|||
|
||||
def self.list( user, limit = 10, type = nil )
|
||||
if !type
|
||||
recent_views = RecentView.where( created_by_id: user.id ).
|
||||
order('created_at DESC, id DESC').
|
||||
limit(limit)
|
||||
recent_views = RecentView.where( created_by_id: user.id )
|
||||
.order('created_at DESC, id DESC')
|
||||
.limit(limit)
|
||||
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) ) .
|
||||
order('created_at DESC, id DESC').
|
||||
limit(limit)
|
||||
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')
|
||||
.limit(limit)
|
||||
end
|
||||
|
||||
list = []
|
||||
|
|
|
@ -80,8 +80,8 @@ returns
|
|||
def self.list(data)
|
||||
# search
|
||||
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 ).
|
||||
order('created_at ASC, id ASC')
|
||||
stores = Store.where( store_object_id: store_object_id, o_id: data[:o_id].to_i )
|
||||
.order('created_at ASC, id ASC')
|
||||
stores
|
||||
end
|
||||
|
||||
|
@ -103,9 +103,9 @@ returns
|
|||
def self.remove(data)
|
||||
# search
|
||||
store_object_id = Store::Object.lookup( name: data[:object] )
|
||||
stores = Store.where( store_object_id: store_object_id ).
|
||||
where( o_id: data[:o_id] ).
|
||||
order('created_at ASC, id ASC')
|
||||
stores = Store.where( store_object_id: store_object_id )
|
||||
.where( o_id: data[:o_id] )
|
||||
.order('created_at ASC, id ASC')
|
||||
stores.each do |store|
|
||||
|
||||
# check backend for references
|
||||
|
|
|
@ -94,10 +94,10 @@ returns
|
|||
def self.access_condition(user)
|
||||
access_condition = []
|
||||
if user.is_role(Z_ROLENAME_AGENT)
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||
where( 'groups_users.user_id = ?', user.id ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||
.where( 'groups_users.user_id = ?', user.id )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
access_condition = [ 'group_id IN (?)', group_ids ]
|
||||
else
|
||||
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
|
||||
|
|
|
@ -108,14 +108,14 @@ returns
|
|||
# @tickets = Ticket.where(:group_id => groups, attributes[:myopenassigned] ).limit(params[:limit])
|
||||
# get only tickets with permissions
|
||||
if data[:current_user].is_role('Customer')
|
||||
group_ids = Group.select( 'groups.id' ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
else
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||
where( 'groups_users.user_id = ?', [ data[:current_user].id ] ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||
.where( 'groups_users.user_id = ?', [ data[:current_user].id ] )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
end
|
||||
|
||||
# overview meta for navbar
|
||||
|
@ -147,20 +147,20 @@ returns
|
|||
if overview_selected.group_by && !overview_selected.group_by.empty?
|
||||
order_by = overview_selected.group_by + '_id, ' + order_by
|
||||
end
|
||||
tickets = Ticket.select( 'id' ).
|
||||
where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
order( order_by ).
|
||||
limit( 500 )
|
||||
tickets = Ticket.select( 'id' )
|
||||
.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.order( order_by )
|
||||
.limit( 500 )
|
||||
|
||||
ticket_ids = []
|
||||
tickets.each { |ticket|
|
||||
ticket_ids.push ticket.id
|
||||
}
|
||||
|
||||
tickets_count = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
count()
|
||||
tickets_count = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.count()
|
||||
|
||||
return {
|
||||
ticket_ids: ticket_ids,
|
||||
|
@ -171,15 +171,15 @@ returns
|
|||
|
||||
# get tickets for overview
|
||||
data[:start_page] ||= 1
|
||||
tickets = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
||||
tickets = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
||||
# 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 ) )
|
||||
|
||||
tickets_count = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
count()
|
||||
tickets_count = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.count()
|
||||
|
||||
{
|
||||
tickets: tickets,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
class Class
|
||||
def to_app_model_url
|
||||
camel_cased_word = self.to_s
|
||||
camel_cased_word.gsub(/::/, '_').
|
||||
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
||||
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
||||
tr('-', '_').
|
||||
downcase
|
||||
camel_cased_word.gsub(/::/, '_')
|
||||
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
||||
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
||||
.tr('-', '_')
|
||||
.downcase
|
||||
end
|
||||
def to_app_model
|
||||
camel_cased_word = self.to_s
|
||||
|
|
Loading…
Reference in a new issue