Small bugfixes.
This commit is contained in:
parent
3e6b8beb00
commit
ab4d98aacb
3 changed files with 15 additions and 12 deletions
|
@ -4,23 +4,19 @@ class Stats::TicketEscalation
|
||||||
|
|
||||||
def self.generate(user)
|
def self.generate(user)
|
||||||
|
|
||||||
|
open_state_ids = Ticket::State.by_category('open').map(&:id)
|
||||||
|
|
||||||
# get users groups
|
# get users groups
|
||||||
group_ids = user.groups.map(&:id)
|
group_ids = user.groups.map(&:id)
|
||||||
|
|
||||||
# owned tickets
|
# owned tickets
|
||||||
own_escalated = Ticket.where(
|
own_escalated = Ticket.where(
|
||||||
owner_id: user.id,
|
'owner_id = ? AND group_id IN (?) AND state_id IN (?) AND escalation_time < ?', user.id, group_ids, open_state_ids, Time.zone.now
|
||||||
group_id: group_ids,
|
|
||||||
escalation_time: Time.zone.now,
|
|
||||||
state_id: Ticket::State.by_category('open').map(&:id)
|
|
||||||
).count
|
).count
|
||||||
|
|
||||||
# all tickets
|
# all tickets
|
||||||
all_escalated = Ticket.where(
|
all_escalated = Ticket.where(
|
||||||
owner_id: user.id,
|
'group_id IN (?) AND state_id IN (?) AND escalation_time < ?', group_ids, open_state_ids, Time.zone.now
|
||||||
group_id: group_ids,
|
|
||||||
escalation_time: Time.zone.now,
|
|
||||||
state_id: Ticket::State.by_category('open').map(&:id)
|
|
||||||
).count
|
).count
|
||||||
|
|
||||||
average = '-'
|
average = '-'
|
||||||
|
|
|
@ -4,10 +4,12 @@ class Stats::TicketInProcess
|
||||||
|
|
||||||
def self.generate(user)
|
def self.generate(user)
|
||||||
|
|
||||||
|
open_state_ids = Ticket::State.by_category('open').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).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(
|
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
|
||||||
|
|
|
@ -4,14 +4,17 @@ class Stats::TicketLoadMeasure
|
||||||
|
|
||||||
def self.generate(user)
|
def self.generate(user)
|
||||||
|
|
||||||
|
open_state_ids = Ticket::State.by_category('open').map(&:id)
|
||||||
|
|
||||||
# owned tickets
|
# 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
|
# 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 = '-'
|
average = '-'
|
||||||
state = 'good'
|
state = 'good'
|
||||||
|
load_measure_precent = 0
|
||||||
# if in_process_precent > 80
|
# if in_process_precent > 80
|
||||||
# state = 'supergood'
|
# state = 'supergood'
|
||||||
# elsif in_process_precent > 60
|
# elsif in_process_precent > 60
|
||||||
|
@ -27,8 +30,10 @@ class Stats::TicketLoadMeasure
|
||||||
if count > total
|
if count > total
|
||||||
total = count
|
total = count
|
||||||
end
|
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,
|
average: average,
|
||||||
percent: load_measure_precent,
|
percent: load_measure_precent,
|
||||||
|
|
Loading…
Reference in a new issue