X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FNodeinfo.php;h=047fe0e58a6c711b27ac195623cb2e80afef0761;hb=073695b33c5f9c5d89d91958b09259c59e12dd98;hp=44181ac941a0ccd9aa3806346a21d4f853e0cc32;hpb=fb7f7435c080e15bdafbbcbb5a3dfd94ef8dd952;p=friendica.git diff --git a/src/Model/Nodeinfo.php b/src/Model/Nodeinfo.php index 44181ac941..047fe0e58a 100644 --- a/src/Model/Nodeinfo.php +++ b/src/Model/Nodeinfo.php @@ -1,6 +1,6 @@ set('nodeinfo', 'active_users_monthly', $userStats['active_users_monthly']); $config->set('nodeinfo', 'active_users_weekly', $userStats['active_users_weekly']); - $logger->debug('user statistics', $userStats); + $logger->info('user statistics', $userStats); - $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); + $posts = DBA::count('post-thread', ["EXISTS(SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin` AND `uri-id` = `post-thread`.`uri-id`)"]); + $comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND EXISTS(SELECT `uri-id` FROM `post-user` WHERE `origin` AND `uri-id` = `post`.`uri-id`)", GRAVITY_COMMENT]); + $config->set('nodeinfo', 'local_posts', $posts); + $config->set('nodeinfo', 'local_comments', $comments); + + $logger->info('User actitivy', ['posts' => $posts, 'comments' => $comments]); } /** @@ -105,7 +102,7 @@ class Nodeinfo * * @return array with supported services */ - public static function getServices() + public static function getServices(): array { $services = [ 'inbound' => [], @@ -160,9 +157,19 @@ class Nodeinfo return $services; } - public static function getOrganization($config) + /** + * Gathers organization information and returns it as an array + * + * @param IManageConfigValues $config Configuration instance + * @return array Organization information + */ + public static function getOrganization(IManageConfigValues $config): array { - $organization = ['name' => null, 'contact' => null, 'account' => null]; + $organization = [ + 'name' => null, + 'contact' => null, + 'account' => null + ]; if (!empty($config->get('config', 'admin_email'))) { $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));