2015-09-06 22:42:11 +00:00
|
|
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class Stats::TicketLoadMeasure
|
|
|
|
|
|
|
|
def self.generate(user)
|
|
|
|
|
2015-09-06 23:17:54 +00:00
|
|
|
open_state_ids = Ticket::State.by_category('open').map(&:id)
|
|
|
|
|
2015-09-06 22:42:11 +00:00
|
|
|
# owned tickets
|
2015-09-06 23:17:54 +00:00
|
|
|
count = Ticket.where(owner_id: user.id, state_id: open_state_ids).count
|
2015-09-06 22:42:11 +00:00
|
|
|
|
|
|
|
# get total open
|
2015-09-06 23:17:54 +00:00
|
|
|
total = Ticket.where(group_id: user.groups.map(&:id), state_id: open_state_ids).count
|
2015-09-06 22:42:11 +00:00
|
|
|
|
|
|
|
average = '-'
|
|
|
|
state = 'good'
|
2015-09-06 23:17:54 +00:00
|
|
|
load_measure_precent = 0
|
2015-09-06 22:42:11 +00:00
|
|
|
# if in_process_precent > 80
|
|
|
|
# state = 'supergood'
|
|
|
|
# elsif in_process_precent > 60
|
|
|
|
# state = 'good'
|
|
|
|
# elsif in_process_precent > 40
|
|
|
|
# state = 'ok'
|
|
|
|
# elsif in_process_precent > 20
|
|
|
|
# state = 'bad'
|
|
|
|
# elsif in_process_precent > 5
|
|
|
|
# state = 'superbad'
|
|
|
|
# end
|
|
|
|
|
|
|
|
if count > total
|
|
|
|
total = count
|
|
|
|
end
|
|
|
|
|
2015-09-06 23:17:54 +00:00
|
|
|
if count != 0 && total != 0
|
|
|
|
load_measure_precent = (count * 1000) / ((total * 1000) / 100)
|
|
|
|
end
|
2015-09-06 22:42:11 +00:00
|
|
|
{
|
|
|
|
average: average,
|
|
|
|
percent: load_measure_precent,
|
|
|
|
state: state,
|
|
|
|
own: count,
|
|
|
|
total: total,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|