Skip to content

Commit

Permalink
Refactor lastupdateResult handling
Browse files Browse the repository at this point in the history
  • Loading branch information
peschmae committed May 20, 2023
1 parent 9be0f62 commit d7e6f1f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/SystemStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,20 @@ public function __construct(IConfig $config, IAppManager $appManager, Installer
public function getSystemStatistics(): array {
$processorUsage = $this->getProcessorUsage();
$memoryUsage = $this->os->getMemory();
$updateInfo = [];
$updateInfo['lastupdatedat'] = (int) $this->config->getAppValue('core', 'lastupdatedat');
$lastUpdateResult = json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
if (is_array($lastUpdateResult)) {
$updateInfo['available'] = ( count($lastUpdateResult) > 0);
if( array_key_exists('version', $lastUpdateResult)) {
$updateInfo['available_version'] = $lastUpdateResult['version'];
}
} else {
$updateInfo['available'] = false;
}
return [
'version' => $this->config->getSystemValue('version'),
'update' => [
'available' => count(json_decode($this->config->getAppValue('core', 'lastupdateResult'), true)) > 0 ? 'yes' : 'no',
'available_version' => json_decode($this->config->getAppValue('core', 'lastupdateResult'), true)['version'] ,
'lastupdatedat' => (int) $this->config->getAppValue('core', 'lastupdatedat'),
],
'update' => $updateInfo,
'theme' => $this->config->getSystemValue('theme', 'none'),
'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
'enable_previews' => $this->config->getSystemValue('enable_previews', true) ? 'yes' : 'no',
Expand Down

0 comments on commit d7e6f1f

Please sign in to comment.