-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from nextcloud/add/copywriter
Add rudimentary copywriter functionality, implement assistant metatask wrapper
- Loading branch information
Showing
42 changed files
with
2,036 additions
and
979 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TpAssistant\Command; | ||
|
||
use Exception; | ||
use OC\Core\Command\Base; | ||
use OCA\TpAssistant\AppInfo\Application; | ||
use OCA\TpAssistant\Db\MetaTaskMapper; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class CleanupAssistantTasks extends Base { | ||
public function __construct( | ||
private MetaTaskMapper $metaTaskMapper, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() { | ||
$maxIdleTimeSetting = Application::DEFAULT_ASSISTANT_TASK_IDLE_TIME; | ||
$this->setName('assistant:task_cleanup') | ||
->setDescription('Cleanup assistant tasks') | ||
->addArgument( | ||
'max_age', | ||
InputArgument::OPTIONAL, | ||
'The max idle time (in seconds)', | ||
$maxIdleTimeSetting | ||
); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$maxAge = intval($input->getArgument('max_age')); | ||
|
||
if ($maxAge < 1) { | ||
$output->writeln('Invalid value for max_age: ' . $maxAge); | ||
return 1; | ||
} | ||
|
||
$output->writeln('Cleanning up assistant tasks older than ' . $maxAge . ' seconds.'); | ||
try { | ||
$cleanedUp = $this->metaTaskMapper->cleanupOldMetaTasks($maxAge); | ||
} catch (Exception $e) { | ||
$output->writeln('Error: ' . $e->getMessage()); | ||
return 1; | ||
} | ||
|
||
$output->writeln('Deleted ' . $cleanedUp . ' idle tasks.'); | ||
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
Oops, something went wrong.