Moved from Ticket::ScreenOptions.agents to generic User.of_role('Agent').

This commit is contained in:
Martin Edenhofer 2015-07-25 16:36:16 +02:00
parent 9c28c50e4b
commit b6b9def375
5 changed files with 21 additions and 22 deletions

View file

@ -61,7 +61,7 @@ class TicketOverviewsController < ApplicationController
group_ids.push group.id group_ids.push group.id
} }
agents = {} agents = {}
Ticket::ScreenOptions.agents.each { |user| User.of_role('Agent').each { |user|
agents[ user.id ] = 1 agents[ user.id ] = 1
} }
groups_users = {} groups_users = {}

View file

@ -202,8 +202,7 @@ cleanup old online notifications
OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 1.days).delete_all OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 1.days).delete_all
# notify all agents # notify all agents
users = Ticket::ScreenOptions.agents User.of_role('Agent').each {|user|
users.each {|user|
Sessions.send_to( Sessions.send_to(
user.id, user.id,
{ {

View file

@ -3,22 +3,6 @@ module Ticket::ScreenOptions
=begin =begin
list of active agents
result = Ticket::ScreenOptions.agents
returns
result = [user1, user2]
=end
def self.agents
User.where( active: true ).joins(:roles).where( 'roles.name' => 'Agent', 'roles.active' => true ).uniq()
end
=begin
list attributes list attributes
result = Ticket::ScreenOptions.attributes_to_change( result = Ticket::ScreenOptions.attributes_to_change(
@ -98,7 +82,7 @@ returns
# get group / user relations # get group / user relations
agents = {} agents = {}
Ticket::ScreenOptions.agents.each { |user| User.of_role('Agent').each { |user|
agents[ user.id ] = 1 agents[ user.id ] = 1
} }

View file

@ -416,6 +416,22 @@ returns
save save
end end
=begin
list of active users in role
result = User.of_role('Agent')
returns
result = [user1, user2]
=end
def self.of_role(role)
User.where(active: true).joins(:roles).where( 'roles.name' => role, 'roles.active' => true ).uniq()
end
private private
def cache_delete def cache_delete

View file

@ -72,11 +72,11 @@ class Sessions::Backend::TicketOverviewList
# get groups # get groups
group_ids = [] group_ids = []
Group.where( active: true ).each { |group| Group.where(active: true).each { |group|
group_ids.push group.id group_ids.push group.id
} }
agents = {} agents = {}
Ticket::ScreenOptions.agents.each { |user| User.of_role('Agent').each { |user|
agents[ user.id ] = 1 agents[ user.id ] = 1
} }
users = {} users = {}