mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
Add admin info to stats Endpoint
This commit is contained in:
parent
e8ab8a84af
commit
7ca4e6e338
4 changed files with 80 additions and 14 deletions
|
@ -24,6 +24,44 @@ class Update
|
|||
|
||||
const NEW_TABLE_STRUCTURE_VERSION = 1288;
|
||||
|
||||
/**
|
||||
* Returns the status of the current update
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getStatus(): int
|
||||
{
|
||||
return (int)DI::config()->get('system', 'update') ?? static::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest Version of the Friendica git repository and null, if this node doesn't check updates automatically
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAvailableVersion(): ?string
|
||||
{
|
||||
return DI::keyValue()->get('git_friendica_version') ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if there's a new update and null if this node doesn't check updates automatically
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public static function isAvailable(): ?bool
|
||||
{
|
||||
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
|
||||
if (version_compare(App::VERSION, static::getAvailableVersion()) < 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if the Database structure needs an update.
|
||||
*
|
||||
|
|
|
@ -188,6 +188,16 @@ class DBStructure
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the Update
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getUpdateStatus(): int
|
||||
{
|
||||
return (int)DI::config()->get('system', 'dbupdate') ?? static::UPDATE_NOT_CHECKED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates DB structure from the installation and returns eventual errors messages
|
||||
*
|
||||
|
|
|
@ -64,23 +64,19 @@ class Summary extends BaseAdmin
|
|||
|
||||
// Check if github.com/friendica/stable/VERSION is higher then
|
||||
// the local version of Friendica. Check is opt-in, source may be stable or develop branch
|
||||
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
|
||||
$gitversion = DI::keyValue()->get('git_friendica_version') ?? '';
|
||||
|
||||
if (version_compare(App::VERSION, $gitversion) < 0) {
|
||||
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, $gitversion);
|
||||
}
|
||||
if (Update::isAvailable()) {
|
||||
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, Update::getAvailableVersion());
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'dbupdate', DBStructure::UPDATE_NOT_CHECKED) == DBStructure::UPDATE_NOT_CHECKED) {
|
||||
if (DBStructure::getUpdateStatus() == DBStructure::UPDATE_NOT_CHECKED) {
|
||||
DBStructure::performUpdate();
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'dbupdate') == DBStructure::UPDATE_FAILED) {
|
||||
if (DBStructure::getUpdateStatus() == DBStructure::UPDATE_FAILED) {
|
||||
$warningtext[] = DI::l10n()->t('The database update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear.');
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'update') == Update::FAILED) {
|
||||
if (Update::getStatus() == Update::FAILED) {
|
||||
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
|
||||
}
|
||||
|
||||
|
@ -160,9 +156,6 @@ class Summary extends BaseAdmin
|
|||
// We can do better, but this is a quick queue status
|
||||
$queues = ['label' => DI::l10n()->t('Message queues'), 'deferred' => $deferred, 'workerq' => $workerqueue];
|
||||
|
||||
$variables = DBA::toArray(DBA::p('SHOW variables LIKE "max_allowed_packet"'));
|
||||
$max_allowed_packet = $variables ? $variables[0]['Value'] : 0;
|
||||
|
||||
$server_settings = [
|
||||
'label' => DI::l10n()->t('Server Settings'),
|
||||
'php' => [
|
||||
|
@ -173,7 +166,7 @@ class Summary extends BaseAdmin
|
|||
'memory_limit' => ini_get('memory_limit')
|
||||
],
|
||||
'mysql' => [
|
||||
'max_allowed_packet' => $max_allowed_packet
|
||||
'max_allowed_packet' => DBA::getVariable('max_allowed_packet'),
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -14,8 +14,11 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
|||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Model\Register;
|
||||
use Friendica\Moderation\Entity\Report;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -23,6 +26,10 @@ use Friendica\Util\Profiler;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
* Returns statistics of the current node for administration use
|
||||
* Like for monitoring
|
||||
*/
|
||||
class Stats extends BaseModule
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
|
@ -129,7 +136,25 @@ class Stats extends BaseModule
|
|||
],
|
||||
'open' => $this->dba->count('report', ['status' => Report::STATUS_OPEN]),
|
||||
'closed' => $this->dba->count('report', ['status' => Report::STATUS_CLOSED]),
|
||||
]
|
||||
],
|
||||
'update' => [
|
||||
'available' => Update::isAvailable(),
|
||||
'available_version' => Update::getAvailableVersion(),
|
||||
'status' => Update::getStatus(),
|
||||
'db_status' => DBStructure::getUpdateStatus(),
|
||||
],
|
||||
'server' => [
|
||||
'version' => App::VERSION,
|
||||
'php' => [
|
||||
'version' => phpversion(),
|
||||
'upload_max_filesize' => ini_get('upload_max_filesize'),
|
||||
'post_max_size' => ini_get('post_max_size'),
|
||||
'memory_limit' => ini_get('memory_limit'),
|
||||
],
|
||||
'database' => [
|
||||
'max_allowed_packet' => DBA::getVariable('max_allowed_packet'),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (Addon::isEnabled('bluesky')) {
|
||||
|
|
Loading…
Reference in a new issue