Skip to content
Snippets Groups Projects
Commit 49e1d225 authored by Peter Rotich's avatar Peter Rotich
Browse files

Ticket Reopen Count

Add ticket reopen count as a column annotation
parent 202f618a
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,10 @@ class Export {
->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
->filter(array('entries__attachments__inline' => 0))
->aggregate(array('count' => SqlAggregate::COUNT('entries__attachments__id'))),
'reopen_count' => TicketThread::objects()
->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
->filter(array('events__annulled' => 0, 'events__state' => 'reopened'))
->aggregate(array('count' => SqlAggregate::COUNT('events__id'))),
'thread_count' => TicketThread::objects()
->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
->exclude(array('entries__flags__hasbit' => ThreadEntry::FLAG_HIDDEN))
......
......@@ -1437,6 +1437,37 @@ extends QueueColumnAnnotation {
}
}
class TicketReopenCount
extends QueueColumnAnnotation {
static $icon = 'folder-open-alt';
static $qname = '_reopen_count';
static $desc = /* @trans */ 'Reopen Count';
function annotate($query) {
return $query->annotate(array(
static::$qname => TicketThread::objects()
->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
->filter(array('events__annulled' => 0, 'events__state' => 'reopened'))
->aggregate(array('count' => SqlAggregate::COUNT('events__id')))
));
}
function getDecoration($row, $text) {
$reopencount = $row[static::$qname];
if ($reopencount) {
return sprintf(
'&nbsp;<small class="faded-more"><i class="icon-%s"></i> %s</small>',
static::$icon,
$reopencount > 1 ? $reopencount : ''
);
}
}
function isVisible($row) {
return $row[static::$qname];
}
}
class ThreadAttachmentCount
extends QueueColumnAnnotation {
static $icon = 'paperclip';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment