Small improvements.
This commit is contained in:
parent
9997a2b119
commit
18893526d9
3 changed files with 20 additions and 13 deletions
|
@ -28,6 +28,7 @@ returns
|
||||||
|
|
||||||
users = User.of_role('Agent')
|
users = User.of_role('Agent')
|
||||||
users.each {|user|
|
users.each {|user|
|
||||||
|
next if user.id == 1
|
||||||
data = {}
|
data = {}
|
||||||
backends.each {|backend|
|
backends.each {|backend|
|
||||||
data[backend.to_app_model] = backend.generate(user)
|
data[backend.to_app_model] = backend.generate(user)
|
||||||
|
|
|
@ -21,17 +21,17 @@ class Stats::TicketEscalation
|
||||||
|
|
||||||
average = '-'
|
average = '-'
|
||||||
state = 'supergood'
|
state = 'supergood'
|
||||||
# if in_process_precent > 80
|
if own_escalated == 0
|
||||||
# state = 'supergood'
|
state = 'supergood'
|
||||||
# elsif in_process_precent > 60
|
elsif own_escalated > 1
|
||||||
# state = 'good'
|
state = 'good'
|
||||||
# elsif in_process_precent > 40
|
elsif own_escalated > 2
|
||||||
# state = 'ok'
|
state = 'ok'
|
||||||
# elsif in_process_precent > 20
|
elsif own_escalated > 5
|
||||||
# state = 'bad'
|
state = 'bad'
|
||||||
# elsif in_process_precent > 5
|
elsif own_escalated > 10
|
||||||
# state = 'superbad'
|
state = 'superbad'
|
||||||
# end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
average: average,
|
average: average,
|
||||||
|
|
|
@ -4,13 +4,19 @@ class Stats::TicketInProcess
|
||||||
|
|
||||||
def self.generate(user)
|
def self.generate(user)
|
||||||
|
|
||||||
open_state_ids = Ticket::State.by_category('open').map(&:id)
|
open_state_ids = Ticket::State.by_category('work_on').map(&:id)
|
||||||
|
pending_state_ids = Ticket::State.by_category('pending_reminder').map(&:id)
|
||||||
|
|
||||||
# get history entries of tickets worked on today
|
# get history entries of tickets worked on today
|
||||||
history_object = History::Object.lookup(name: 'Ticket')
|
history_object = History::Object.lookup(name: 'Ticket')
|
||||||
|
|
||||||
own_ticket_ids = Ticket.select('id').where(owner_id: user.id, state_id: open_state_ids).map(&:id)
|
# get own tickets which are "workable"
|
||||||
|
own_ticket_ids = Ticket.select('id').where(
|
||||||
|
'owner_id = ? AND (state_id IN (?) OR (state_id IN (?) AND pending_time < ?))',
|
||||||
|
user.id, open_state_ids, pending_state_ids, Time.zone.now
|
||||||
|
).limit(1000).map(&:id)
|
||||||
|
|
||||||
|
# get count where user worked on
|
||||||
count = History.select('DISTINCT(o_id)').where(
|
count = History.select('DISTINCT(o_id)').where(
|
||||||
'histories.created_at >= ? AND histories.history_object_id = ? AND histories.created_by_id = ? AND histories.o_id IN (?)', Time.zone.now - 1.day, history_object.id, user.id, own_ticket_ids
|
'histories.created_at >= ? AND histories.history_object_id = ? AND histories.created_by_id = ? AND histories.o_id IN (?)', Time.zone.now - 1.day, history_object.id, user.id, own_ticket_ids
|
||||||
).count
|
).count
|
||||||
|
|
Loading…
Reference in a new issue