-- ------------------------------------------
-- Friendica 2023.03-dev (Giant Rhubarb)
--- DB_UPDATE_VERSION 1511
+-- DB_UPDATE_VERSION 1512
-- ------------------------------------------
$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]);
}
$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'));
}
}
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;
{
/** @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();
}
'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);
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Protocol;
use Friendica\Database\Database;
-use Friendica\Database\DBA;
use Friendica\DI;
/**
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]);
}
}
}
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1511);
+ define('DB_UPDATE_VERSION', 1512);
}
return [
}
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');
+}