Hello,
I have created a patch for this that works fine in my tests.
Is it possible to integrate it into a future update, or could this cause potential problems?

function getRoughCount() {
if (($count = $this->getRoughCountAPC()) !== false)
return $count;
$query = Ticket::objects();
$Q = $this->getBasicQuery();
$expr = SqlCase::N();
// Prüfen, ob mehrere Custom Conditions definiert sind
if (is_array($Q->constraints)) {
foreach ($Q->constraints as $condition) {
// Jede Bedingung korrekt in einen SQL-Ausdruck umwandeln
$expr->when(new SqlExpr(new Q($condition)), new SqlField('ticket_id'));
}
} else {
// Fallback: Einzelbedingung wie bisher
$expr->when(new SqlExpr(new Q($Q->constraints)), new SqlField('ticket_id'));
}
$query = $query->aggregate(array(
"ticket_count" => SqlAggregate::COUNT($expr)
));
$row = $query->values()->one();
return $row['ticket_count'];
}
function getRoughCountAPC() {
if (!function_exists('apcu_store'))
return false;
$key = "rough.counts.".SECRET_SALT;
$cached = false;
$counts = apcu_fetch($key, $cached);
if ($cached === true && isset($counts["q{$this->id}"]))
return $counts["q{$this->id}"];
// Fetch rough counts of all queues. That is, fetch a total of the
// counts based on the queue criteria alone. Do no consider agent
// access. This should be fast and "rought"
$queues = static::objects()
->filter(['flags__hasbit' => CustomQueue::FLAG_PUBLIC])
->exclude(['flags__hasbit' => CustomQueue::FLAG_DISABLED]);
$query = Ticket::objects();
$prefix = "";
foreach ($queues as $queue) {
$Q = $queue->getBasicQuery();
$expr = SqlCase::N();
// Prüfen, ob mehrere Custom Conditions definiert sind
if (is_array($Q->constraints)) {
foreach ($Q->constraints as $condition) {
// Jede Bedingung korrekt in einen SQL-Ausdruck umwandeln
$expr->when(new SqlExpr(new Q($condition)), new SqlField('ticket_id'));
}
} else {
// Fallback: Einzelbedingung wie bisher
$expr->when(new SqlExpr(new Q($Q->constraints)), new SqlField('ticket_id'));
}
$query = $query->aggregate(array(
"q{$queue->id}" => SqlAggregate::COUNT($expr)
));
}
$counts = $query->values()->one();
apcu_store($key, $counts, 900);
return @$counts["q{$this->id}"];
}