From 836d51775ea536265bbef61837b6b24deb76420d Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 27 Mar 2015 15:44:02 -0500 Subject: [PATCH] Fix thread and attachment counts on ticket queues --- include/staff/tickets.inc.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 9f0fa3db0..8f6a86ce8 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -150,10 +150,7 @@ if (!$view_all_tickets) { if ($teams = array_filter($thisstaff->getTeams())) $assigned->add(array('team_id__in' => $teams)); - if ($status) - $visibility = Q::any(array($assigned)); - else - $visibility = Q::any(array('status__state'=>'open', $assigned)); + $visibility = Q::any(array('status__state'=>'open', $assigned)); // -- Routed to a department of mine if (!$thisstaff->showAssignedOnly() && ($depts=$thisstaff->getDepts())) @@ -268,13 +265,18 @@ $tickets->values('lock__staff_id', 'staff_id', 'isoverdue', 'team_id', 'ticket_i // Add in annotations $tickets->annotate(array( - 'collab_count' => SqlAggregate::COUNT('thread__collaborators'), - 'attachment_count' => SqlAggregate::COUNT('thread__entries__attachments'), + 'collab_count' => SqlAggregate::COUNT('thread__collaborators', true), + 'attachment_count' => SqlAggregate::COUNT(SqlCase::N() + ->when(new SqlField('thread__entries__attachments__inline'), null) + ->otherwise(new SqlField('thread__entries__attachments')), + true + ), 'thread_count' => SqlAggregate::COUNT(SqlCase::N() ->when( new Q(array('thread__entries__flags__hasbit'=>ThreadEntry::FLAG_HIDDEN)), null) - ->otherwise(1) + ->otherwise(new SqlField('thread__entries__id')), + true ), )); -- GitLab