forked from nextcloud/richdocuments
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement commands: cleanup-tags & reset-tags
Fixes nextcloud#127
- Loading branch information
1 parent
0e1e3a4
commit 3c52929
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace OCA\Recognize\Command; | ||
|
||
use OCA\Recognize\Service\ClassifyImagesService; | ||
use OCA\Recognize\Service\Logger; | ||
use OCA\Recognize\Service\TagManager; | ||
use OCP\IUser; | ||
use OCP\IUserManager; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class CleanupTags extends Command { | ||
/** | ||
* @var \OCA\Recognize\Service\TagManager | ||
*/ | ||
private $tagManager; | ||
|
||
|
||
public function __construct(TagManager $tagManager) { | ||
parent::__construct(); | ||
$this->tagManager = $tagManager; | ||
} | ||
|
||
/** | ||
* Configure the command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() { | ||
$this->setName('recognize:cleanup-tags') | ||
->setDescription('Delete all tags that have no files associated with them anymore'); | ||
} | ||
|
||
/** | ||
* Execute the command | ||
* | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
try { | ||
$this->tagManager->removeEmptyTags(); | ||
} catch (\Exception $ex) { | ||
$output->writeln('<error>Failed to clean up tags</error>'); | ||
$output->writeln($ex->getMessage()); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace OCA\Recognize\Command; | ||
|
||
use OCA\Recognize\Service\ClassifyImagesService; | ||
use OCA\Recognize\Service\Logger; | ||
use OCA\Recognize\Service\TagManager; | ||
use OCP\IUser; | ||
use OCP\IUserManager; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ResetTags extends Command { | ||
/** | ||
* @var \OCA\Recognize\Service\TagManager | ||
*/ | ||
private $tagManager; | ||
|
||
|
||
public function __construct(TagManager $tagManager) { | ||
parent::__construct(); | ||
$this->tagManager = $tagManager; | ||
} | ||
|
||
/** | ||
* Configure the command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() { | ||
$this->setName('recognize:reset-tags') | ||
->setDescription('Remove all tags from previously classified files'); | ||
} | ||
|
||
/** | ||
* Execute the command | ||
* | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
try { | ||
$this->tagManager->resetClassifications(); | ||
} catch (\Exception $ex) { | ||
$output->writeln('<error>Failed to reset tags</error>'); | ||
$output->writeln($ex->getMessage()); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters