Small improvements.

This commit is contained in:
Martin Edenhofer 2015-09-07 01:52:54 +02:00
parent 9997a2b119
commit 18893526d9
3 changed files with 20 additions and 13 deletions

View file

@ -28,6 +28,7 @@ returns
users = User.of_role('Agent')
users.each {|user|
next if user.id == 1
data = {}
backends.each {|backend|
data[backend.to_app_model] = backend.generate(user)

View file

@ -21,17 +21,17 @@ class Stats::TicketEscalation
average = '-'
state = 'supergood'
# 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 own_escalated == 0
state = 'supergood'
elsif own_escalated > 1
state = 'good'
elsif own_escalated > 2
state = 'ok'
elsif own_escalated > 5
state = 'bad'
elsif own_escalated > 10
state = 'superbad'
end
{
average: average,

View file

@ -4,13 +4,19 @@ class Stats::TicketInProcess
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
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(
'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