Skip to content
Permalink
Browse files

Ticket Task count

This commit adds a ticket queue decoration for tasks count as well as option
to export same.
  • Loading branch information...
protich committed Oct 11, 2019
1 parent 919e1b7 commit b4fca250ed64f736cfa01e45765786841e57e610
Showing with 44 additions and 0 deletions.
  1. +30 −0 include/class.queue.php
  2. +11 −0 include/class.search.php
  3. +3 −0 include/class.ticket.php
@@ -618,6 +618,7 @@ function getExportableFields() {
'thread_count' => __('Thread Count'),
'reopen_count' => __('Reopen Count'),
'attachment_count' => __('Attachment Count'),
'task_count' => __('Task Count'),
) + $cdata;
return $fields;
@@ -1715,6 +1716,35 @@ function isVisible($row) {
}
}
class TicketTasksCount
extends QueueColumnAnnotation {
static $icon = 'list-ol';
static $qname = '_task_count';
static $desc = /* @trans */ 'Tasks Count';
function annotate($query, $name=false) {
$name = $name ?: static::$qname;
return $query->annotate(array(
$name => Task::objects()
->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
->aggregate(array('count' => SqlAggregate::COUNT('id')))
));
}
function getDecoration($row, $text) {
$count = $row[static::$qname];
if ($count) {
return sprintf(
'<small class="faded-more"><i class="icon-%s"></i> %s</small>',
static::$icon, $count);
}
}
function isVisible($row) {
return $row[static::$qname];
}
}
class ThreadCollaboratorCount
extends QueueColumnAnnotation {
static $icon = 'group';
@@ -1783,6 +1783,17 @@ function from_query($row, $name=false) {
}
}
class TicketTasksCountField extends NumericField {
function addToQuery($query, $name=false) {
return TicketTasksCount::addToQuery($query, $name);
}
function from_query($row, $name=false) {
return TicketTasksCount::from_query($row, $name);
}
}
interface Searchable {
// Fetch an array of [ orm__path => Field() ] pairs. The field label is
// used when this list is rendered in a dropdown, and the field search
@@ -2327,6 +2327,9 @@ static function getSearchableFields() {
'collaborator_count' => new ThreadCollaboratorCountField(array(
'label' => __('Collaborator Count'),
)),
'task_count' => new TicketTasksCountField(array(
'label' => __('Task Count'),
)),
'reopen_count' => new TicketReopenCountField(array(
'label' => __('Reopen Count'),
)),

0 comments on commit b4fca25

Please sign in to comment.
You can’t perform that action at this time.