Skip to content

Commit

Permalink
display database type
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Nov 10, 2021
1 parent 4fd3bfb commit 2609940
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions lib/Command/PointList.php
Expand Up @@ -35,6 +35,7 @@
use ArtificialOwl\MySmallPhpTools\Exceptions\SignatureException;
use ArtificialOwl\MySmallPhpTools\Traits\TStringTools;
use OC\Core\Command\Base;
use OCA\Backup\Model\RestoringData;
use OCA\Backup\Model\RestoringHealth;
use OCA\Backup\Model\RestoringPoint;
use OCA\Backup\Service\CronService;
Expand Down Expand Up @@ -125,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$table = new Table($output);
$table->setHeaders(
['Restoring Point', 'Date', 'NC', 'Parent', 'Comment', 'Status', 'Instance', 'Health']
['Restoring Point', 'Date', 'NC', 'Database', 'Parent', 'Comment', 'Status', 'Instance', 'Health']
);
$table->render();

Expand Down Expand Up @@ -162,9 +163,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$table->appendRow(
[
'<comment>' . (($point->isLocked()) ? 'L' : '') .
(($point->isArchive()) ? 'A' : '') . '</comment> ' . (($fresh) ? $displayPointId : ''),
(($point->isArchive()) ? 'A' : '') . '</comment> '
. (($fresh) ? $displayPointId : ''),
($fresh) ? date('Y-m-d H:i:s', $point->getDate()) : '',
($fresh) ? $point->getNCVersion() : '',
($fresh) ? $this->getDatabaseType($point) : '',
($fresh) ? $point->getParent() : '',
$comment,
implode(',', $status),
Expand Down Expand Up @@ -211,4 +214,26 @@ private function displayStyleHealth(RestoringPoint $point): string {

return '<' . $embed . '>' . $def . '</' . $embed . '>';
}


/**
* @param RestoringPoint $point
*
* @return string
*/
private function getDatabaseType(RestoringPoint $point): string {
foreach ($point->getRestoringData() as $data) {
if ($data->getType() === RestoringData::FILE_SQL_DUMP) {
$chunks = $data->getChunks();
if (sizeof($chunks) === 1) {
$chunk = array_shift($chunks);

return $chunk->getType();
}
}
}

return 'sqlite';
}

}

0 comments on commit 2609940

Please sign in to comment.