Skip to content
Snippets Groups Projects
Unverified Commit 4781bf0d authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #5285 from aydreeihn/issue/incorrectly-saved-queue

Issue: DB Error #1064 Queue Counts
parents e5ac9858 f26ce604
No related branches found
No related tags found
No related merge requests found
......@@ -904,10 +904,22 @@ class SavedQueue extends CustomQueue {
// Aggregate constraints
foreach ($queues as $queue) {
$Q = $queue->getBasicQuery();
$expr = SqlCase::N()->when(new SqlExpr(new Q($Q->constraints)), new SqlField('ticket_id'));
$query->aggregate(array(
"q{$queue->id}" => SqlAggregate::COUNT($expr, true)
));
if ($Q->constraints) {
$empty = false;
if (count($Q->constraints) > 1) {
foreach ($Q->constraints as $key => $value) {
if (!$value->constraints)
$empty = true;
}
}
if (!$empty) {
$expr = SqlCase::N()->when(new SqlExpr(new Q($Q->constraints)), new SqlField('ticket_id'));
$query->aggregate(array(
"q{$queue->id}" => SqlAggregate::COUNT($expr, true)
));
}
}
// Add extra tables joins (if any)
if ($Q->extra && isset($Q->extra['tables'])) {
......
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