Cleanup.
This commit is contained in:
parent
458d700db3
commit
b921b8782a
2 changed files with 5 additions and 8 deletions
|
@ -4,13 +4,9 @@ class Stats::TicketInProcess
|
||||||
|
|
||||||
def self.generate(user)
|
def self.generate(user)
|
||||||
|
|
||||||
|
# get own tickets which are "workable"
|
||||||
open_state_ids = Ticket::State.by_category('work_on').map(&:id)
|
open_state_ids = Ticket::State.by_category('work_on').map(&:id)
|
||||||
pending_state_ids = Ticket::State.by_category('pending_reminder').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')
|
|
||||||
|
|
||||||
# get own tickets which are "workable"
|
|
||||||
own_ticket_ids = Ticket.select('id').where(
|
own_ticket_ids = Ticket.select('id').where(
|
||||||
'owner_id = ? AND (state_id IN (?) OR (state_id IN (?) AND pending_time < ?))',
|
'owner_id = ? AND (state_id IN (?) OR (state_id IN (?) AND pending_time < ?))',
|
||||||
user.id, open_state_ids, pending_state_ids, Time.zone.now
|
user.id, open_state_ids, pending_state_ids, Time.zone.now
|
||||||
|
@ -33,6 +29,7 @@ class Stats::TicketInProcess
|
||||||
all_ticket_ids = own_ticket_ids.concat(closed_ticket_ids).concat(pending_action_ticket_ids).uniq
|
all_ticket_ids = own_ticket_ids.concat(closed_ticket_ids).concat(pending_action_ticket_ids).uniq
|
||||||
|
|
||||||
# get count where user worked on
|
# get count where user worked on
|
||||||
|
history_object = History::Object.lookup(name: 'Ticket')
|
||||||
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, all_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, all_ticket_ids
|
||||||
).count
|
).count
|
||||||
|
|
Loading…
Reference in a new issue