Nodeinfo data has moved to key values
This commit is contained in:
parent
4b73335def
commit
73e163100c
6 changed files with 45 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2023.03-dev (Giant Rhubarb)
|
||||
-- DB_UPDATE_VERSION 1511
|
||||
-- DB_UPDATE_VERSION 1512
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -55,17 +55,17 @@ class Nodeinfo
|
|||
|
||||
$userStats = User::getStatistics();
|
||||
|
||||
$config->set('nodeinfo', 'total_users', $userStats['total_users']);
|
||||
$config->set('nodeinfo', 'active_users_halfyear', $userStats['active_users_halfyear']);
|
||||
$config->set('nodeinfo', 'active_users_monthly', $userStats['active_users_monthly']);
|
||||
$config->set('nodeinfo', 'active_users_weekly', $userStats['active_users_weekly']);
|
||||
DI::keyValue()->set('nodeinfo_total_users', $userStats['total_users']);
|
||||
DI::keyValue()->set('nodeinfo_active_users_halfyear', $userStats['active_users_halfyear']);
|
||||
DI::keyValue()->set('nodeinfo_active_users_monthly', $userStats['active_users_monthly']);
|
||||
DI::keyValue()->set('nodeinfo_active_users_weekly', $userStats['active_users_weekly']);
|
||||
|
||||
$logger->info('user statistics', $userStats);
|
||||
|
||||
$posts = DBA::count('post-thread', ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE NOT `deleted` AND `origin`)"]);
|
||||
$comments = DBA::count('post', ["NOT `deleted` AND `gravity` = ? AND `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)", Item::GRAVITY_COMMENT]);
|
||||
$config->set('nodeinfo', 'local_posts', $posts);
|
||||
$config->set('nodeinfo', 'local_comments', $comments);
|
||||
DI::keyValue()->set('nodeinfo_local_posts', $posts);
|
||||
DI::keyValue()->set('nodeinfo_local_comments', $comments);
|
||||
|
||||
$logger->info('User actitivy', ['posts' => $posts, 'comments' => $comments]);
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ class Nodeinfo
|
|||
$usage->users = new \stdClass;
|
||||
|
||||
if (!empty($config->get('system', 'nodeinfo'))) {
|
||||
$usage->users->total = intval($config->get('nodeinfo', 'total_users'));
|
||||
$usage->users->activeHalfyear = intval($config->get('nodeinfo', 'active_users_halfyear'));
|
||||
$usage->users->activeMonth = intval($config->get('nodeinfo', 'active_users_monthly'));
|
||||
$usage->localPosts = intval($config->get('nodeinfo', 'local_posts'));
|
||||
$usage->localComments = intval($config->get('nodeinfo', 'local_comments'));
|
||||
$usage->users->total = intval(DI::keyValue()->get('nodeinfo_total_users'));
|
||||
$usage->users->activeHalfyear = intval(DI::keyValue()->get('nodeinfo_active_users_halfyear'));
|
||||
$usage->users->activeMonth = intval(DI::keyValue()->get('nodeinfo_active_users_monthly'));
|
||||
$usage->localPosts = intval(DI::keyValue()->get('nodeinfo_local_posts'));
|
||||
$usage->localComments = intval(DI::keyValue()->get('nodeinfo_local_comments'));
|
||||
|
||||
if ($version2) {
|
||||
$usage->users->activeWeek = intval($config->get('nodeinfo', 'active_users_weekly'));
|
||||
$usage->users->activeWeek = intval(DI::keyValue()->get('nodeinfo_active_users_weekly'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
@ -35,13 +36,15 @@ class Statistics extends BaseModule
|
|||
{
|
||||
/** @var IManageConfigValues */
|
||||
protected $config;
|
||||
|
||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, Response $response, array $server, array $parameters = [])
|
||||
/** @var IManageKeyValuePairs */
|
||||
protected $keyValue;
|
||||
|
||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
if (!$this->config->get("system", "nodeinfo")) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
@ -72,10 +75,10 @@ class Statistics extends BaseModule
|
|||
'network' => App::PLATFORM,
|
||||
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
|
||||
'registrations_open' => $registration_open,
|
||||
'total_users' => $this->config->get('nodeinfo', 'total_users'),
|
||||
'active_users_halfyear' => $this->config->get('nodeinfo', 'active_users_halfyear'),
|
||||
'active_users_monthly' => $this->config->get('nodeinfo', 'active_users_monthly'),
|
||||
'local_posts' => $this->config->get('nodeinfo', 'local_posts'),
|
||||
'total_users' => $this->keyValue->get('nodeinfo_total_users'),
|
||||
'active_users_halfyear' => $this->keyValue->get('nodeinfo_active_users_halfyear'),
|
||||
'active_users_monthly' => $this->keyValue->get('nodeinfo_active_users_monthly'),
|
||||
'local_posts' => $this->keyValue->get('nodeinfo_local_posts'),
|
||||
'services' => $services,
|
||||
], $services);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\BaseDataTransferObject;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
|
@ -45,9 +44,9 @@ class Stats extends BaseDataTransferObject
|
|||
public function __construct(IManageConfigValues $config, Database $database)
|
||||
{
|
||||
if (!empty($config->get('system', 'nodeinfo'))) {
|
||||
$this->user_count = intval($config->get('nodeinfo', 'total_users'));
|
||||
$this->status_count = $config->get('nodeinfo', 'local_posts') + $config->get('nodeinfo', 'local_comments');
|
||||
$this->domain_count = $database->count('gserver', ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
|
||||
$this->user_count = intval(DI::keyValue()->get('nodeinfo_total_users'));
|
||||
$this->status_count = DI::keyValue()->get('nodeinfo_local_posts') + DI::keyValue()->get('nodeinfo_local_comments');
|
||||
$this->domain_count = $database->count('gserver', ["`network` in (?, ?) AND NOT `failed` AND NOT `blocked`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1511);
|
||||
define('DB_UPDATE_VERSION', 1512);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
17
update.php
17
update.php
|
@ -1227,3 +1227,20 @@ function update_1510()
|
|||
}
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
function update_1512()
|
||||
{
|
||||
DI::keyValue()->set('nodeinfo_total_users', DI::config()->get('nodeinfo', 'total_users'));
|
||||
DI::keyValue()->set('nodeinfo_active_users_halfyear', DI::config()->get('nodeinfo', 'active_users_halfyear'));
|
||||
DI::keyValue()->set('nodeinfo_active_users_monthly', DI::config()->get('nodeinfo', 'active_users_monthly'));
|
||||
DI::keyValue()->set('nodeinfo_active_users_weekly', DI::config()->get('nodeinfo', 'active_users_weekly'));
|
||||
DI::keyValue()->set('nodeinfo_local_posts', DI::config()->get('nodeinfo', 'local_posts'));
|
||||
DI::keyValue()->set('nodeinfo_local_comments', DI::config()->get('nodeinfo', 'local_comments'));
|
||||
|
||||
DI::config()->delete('nodeinfo', 'total_users');
|
||||
DI::config()->delete('nodeinfo', 'active_users_halfyear');
|
||||
DI::config()->delete('nodeinfo', 'active_users_monthly');
|
||||
DI::config()->delete('nodeinfo', 'active_users_weekly');
|
||||
DI::config()->delete('nodeinfo', 'local_posts');
|
||||
DI::config()->delete('nodeinfo', 'local_comments');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue