The item count is now done in a single query
This commit is contained in:
parent
a5895f8623
commit
db98040521
|
@ -52,12 +52,15 @@ class Nodeinfo
|
||||||
|
|
||||||
$logger->debug('user statistics', $userStats);
|
$logger->debug('user statistics', $userStats);
|
||||||
|
|
||||||
$local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
|
$items = DBA::p("SELECT COUNT(*) AS `total`, `gravity` FROM `item` WHERE `origin` AND NOT `deleted` AND `uid` != 0 AND `gravity` IN (?, ?) GROUP BY `gravity`",
|
||||||
$config->set('nodeinfo', 'local_posts', $local_posts);
|
GRAVITY_PARENT, GRAVITY_COMMENT);
|
||||||
$logger->debug('thread statistics', ['local_posts' => $local_posts]);
|
while ($item = DBA::fetch($items)) {
|
||||||
|
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||||
$local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
|
$config->set('nodeinfo', 'local_posts', $item['total']);
|
||||||
$config->set('nodeinfo', 'local_comments', $local_comments);
|
} elseif ($item['gravity'] == GRAVITY_COMMENT) {
|
||||||
$logger->debug('item statistics', ['local_comments' => $local_comments]);
|
$config->set('nodeinfo', 'local_comments', $item['total']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBA::close($items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue