1
1
Fork 0

Merge pull request #8093 from annando/postcount

The item count is now done in a single query
This commit is contained in:
Philipp 2020-01-11 16:02:47 +01:00 committed by GitHub
commit fa39a455a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,12 +52,15 @@ class Nodeinfo
$logger->debug('user statistics', $userStats);
$local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
$config->set('nodeinfo', 'local_posts', $local_posts);
$logger->debug('thread statistics', ['local_posts' => $local_posts]);
$local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
$config->set('nodeinfo', 'local_comments', $local_comments);
$logger->debug('item statistics', ['local_comments' => $local_comments]);
$items = DBA::p("SELECT COUNT(*) AS `total`, `gravity` FROM `item` WHERE `origin` AND NOT `deleted` AND `uid` != 0 AND `gravity` IN (?, ?) GROUP BY `gravity`",
GRAVITY_PARENT, GRAVITY_COMMENT);
while ($item = DBA::fetch($items)) {
if ($item['gravity'] == GRAVITY_PARENT) {
$config->set('nodeinfo', 'local_posts', $item['total']);
} elseif ($item['gravity'] == GRAVITY_COMMENT) {
$config->set('nodeinfo', 'local_comments', $item['total']);
}
}
DBA::close($items);
}
}