X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FNodeinfo.php;h=d39641553114acc8fa527b36f40457a5b6504e80;hb=7b7132971a64a92a685a5fd860fe4709dce1765a;hp=60eba2713aecbca6188b21a7357392ee462afa68;hpb=5233434d94c9b783755e7a5e43327d696761341b;p=friendica.git diff --git a/src/Model/Nodeinfo.php b/src/Model/Nodeinfo.php index 60eba2713a..d396415531 100644 --- a/src/Model/Nodeinfo.php +++ b/src/Model/Nodeinfo.php @@ -1,15 +1,34 @@ . + * + */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Core\Addon; use Friendica\Database\DBA; +use Friendica\DI; /** * Model interaction for the nodeinfo */ -class Nodeinfo extends BaseObject +class Nodeinfo { /** * Updates the info about the current node @@ -18,9 +37,8 @@ class Nodeinfo extends BaseObject */ public static function update() { - $app = self::getApp(); - $config = $app->getConfig(); - $logger = $app->getLogger(); + $config = DI::config(); + $logger = DI::logger(); // If the addon 'statistics_json' is enabled then disable it and activate nodeinfo. if (Addon::isEnabled('statistics_json')) { @@ -53,12 +71,15 @@ class Nodeinfo extends BaseObject $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); } }