]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Nodeinfo.php
Replace profile tab GET parameter by route
[friendica.git] / src / Model / Nodeinfo.php
index f6deb31bd5d8a412fbb46a3a95091074ac4d6241..7cde259538c95b26ced1c3f0ffe3b8bc832305bc 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Friendica\Model;
 
-use Friendica\BaseObject;
 use Friendica\Core\Addon;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -10,7 +9,7 @@ use Friendica\DI;
 /**
  * Model interaction for the nodeinfo
  */
-class Nodeinfo extends BaseObject
+class Nodeinfo
 {
        /**
         * Updates the info about the current node
@@ -19,9 +18,8 @@ class Nodeinfo extends BaseObject
         */
        public static function update()
        {
-               $app = DI::app();
-               $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')) {
@@ -54,12 +52,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);
        }
 }