2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2015-09-06 22:42:11 +00:00
|
|
|
|
|
|
|
class Stats::TicketEscalation
|
|
|
|
|
|
|
|
def self.generate(user)
|
|
|
|
|
2017-03-27 14:06:18 +00:00
|
|
|
open_state_ids = Ticket::State.by_category(:open).pluck(:id)
|
2015-09-06 23:17:54 +00:00
|
|
|
|
2015-09-06 22:42:11 +00:00
|
|
|
# get users groups
|
2017-06-16 20:43:09 +00:00
|
|
|
group_ids = user.group_ids_access('full')
|
2015-09-06 22:42:11 +00:00
|
|
|
|
|
|
|
# owned tickets
|
|
|
|
own_escalated = Ticket.where(
|
2016-09-14 07:15:30 +00:00
|
|
|
'owner_id = ? AND group_id IN (?) AND state_id IN (?) AND escalation_at < ?', user.id, group_ids, open_state_ids, Time.zone.now
|
2015-09-06 22:42:11 +00:00
|
|
|
).count
|
|
|
|
|
|
|
|
# all tickets
|
|
|
|
all_escalated = Ticket.where(
|
2016-09-14 07:15:30 +00:00
|
|
|
'group_id IN (?) AND state_id IN (?) AND escalation_at < ?', group_ids, open_state_ids, Time.zone.now
|
2015-09-06 22:42:11 +00:00
|
|
|
).count
|
|
|
|
|
|
|
|
average = '-'
|
2016-01-16 10:05:04 +00:00
|
|
|
state = if own_escalated.zero?
|
2016-01-15 17:22:57 +00:00
|
|
|
'supergood'
|
|
|
|
elsif own_escalated <= 1
|
|
|
|
'good'
|
|
|
|
elsif own_escalated <= 4
|
|
|
|
'ok'
|
|
|
|
else
|
|
|
|
'bad'
|
|
|
|
end
|
2015-09-06 22:42:11 +00:00
|
|
|
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
used_for_average: own_escalated,
|
2015-09-08 06:55:09 +00:00
|
|
|
average_per_agent: average,
|
2018-12-19 17:31:51 +00:00
|
|
|
state: state,
|
|
|
|
own: own_escalated,
|
|
|
|
total: all_escalated,
|
2015-09-06 22:42:11 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-09-08 10:59:46 +00:00
|
|
|
def self.average_state(result, _user_id)
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2015-09-06 22:42:11 +00:00
|
|
|
end
|