Small bugfixes.

This commit is contained in:
Martin Edenhofer 2015-09-07 01:17:54 +02:00
parent 3e6b8beb00
commit ab4d98aacb
3 changed files with 15 additions and 12 deletions

View file

@ -4,23 +4,19 @@ class Stats::TicketEscalation
def self.generate(user)
open_state_ids = Ticket::State.by_category('open').map(&:id)
# get users groups
group_ids = user.groups.map(&:id)
# owned tickets
own_escalated = Ticket.where(
owner_id: user.id,
group_id: group_ids,
escalation_time: Time.zone.now,
state_id: Ticket::State.by_category('open').map(&:id)
'owner_id = ? AND group_id IN (?) AND state_id IN (?) AND escalation_time < ?', user.id, group_ids, open_state_ids, Time.zone.now
).count
# all tickets
all_escalated = Ticket.where(
owner_id: user.id,
group_id: group_ids,
escalation_time: Time.zone.now,
state_id: Ticket::State.by_category('open').map(&:id)
'group_id IN (?) AND state_id IN (?) AND escalation_time < ?', group_ids, open_state_ids, Time.zone.now
).count
average = '-'

View file

@ -4,10 +4,12 @@ class Stats::TicketInProcess
def self.generate(user)
open_state_ids = Ticket::State.by_category('open').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).map(&:id)
own_ticket_ids = Ticket.select('id').where(owner_id: user.id, state_id: open_state_ids).map(&:id)
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

View file

@ -4,14 +4,17 @@ class Stats::TicketLoadMeasure
def self.generate(user)
open_state_ids = Ticket::State.by_category('open').map(&:id)
# owned tickets
count = Ticket.where(owner_id: user.id).count
count = Ticket.where(owner_id: user.id, state_id: open_state_ids).count
# get total open
total = Ticket.where(group_id: user.groups.map(&:id), state_id: Ticket::State.by_category('open').map(&:id) ).count
total = Ticket.where(group_id: user.groups.map(&:id), state_id: open_state_ids).count
average = '-'
state = 'good'
load_measure_precent = 0
# if in_process_precent > 80
# state = 'supergood'
# elsif in_process_precent > 60
@ -27,8 +30,10 @@ class Stats::TicketLoadMeasure
if count > total
total = count
end
load_measure_precent = (count * 1000) / ((total * 1000) / 100)
if count != 0 && total != 0
load_measure_precent = (count * 1000) / ((total * 1000) / 100)
end
{
average: average,
percent: load_measure_precent,