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
}
agents = {}
Ticket::ScreenOptions.agents.each { |user|
User.of_role('Agent').each { |user|
agents[ user.id ] = 1
}
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
# notify all agents
users = Ticket::ScreenOptions.agents
users.each {|user|
User.of_role('Agent').each {|user|
Sessions.send_to(
user.id,
{

View file

@ -3,22 +3,6 @@ module Ticket::ScreenOptions
=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
result = Ticket::ScreenOptions.attributes_to_change(
@ -98,7 +82,7 @@ returns
# get group / user relations
agents = {}
Ticket::ScreenOptions.agents.each { |user|
User.of_role('Agent').each { |user|
agents[ user.id ] = 1
}

View file

@ -416,6 +416,22 @@ returns
save
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
def cache_delete

View file

@ -76,7 +76,7 @@ class Sessions::Backend::TicketOverviewList
group_ids.push group.id
}
agents = {}
Ticket::ScreenOptions.agents.each { |user|
User.of_role('Agent').each { |user|
agents[ user.id ] = 1
}
users = {}