Skip to content

Commit

Permalink
feat: Add cleanup maintenance command
Browse files Browse the repository at this point in the history
  • Loading branch information
mugge6 committed Jun 5, 2023
1 parent 65cc869 commit ad0d232
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/ProcessManagerBundle/Controller/ProcessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Pimcore\Db;
use ProcessManagerBundle\Model\Process;
use ProcessManagerBundle\Model\ProcessInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -106,14 +107,14 @@ public function stopAction(Request $request): JsonResponse
);
}

public function clearAction(Request $request): JsonResponse
public function clearAction(Request $request, ParameterBagInterface $parameterBag): JsonResponse
{
$seconds = (int)$request->get('seconds', 604_800);
$connection = Db::get();
$connection->executeStatement('DELETE FROM process_manager_processes WHERE started < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL ? SECOND))', [$seconds]);

$logDirectory = \Pimcore::getContainer()->getParameter('process_manager.log_directory');
$keepLogs = \Pimcore::getContainer()->getParameter('process_manager.keep_logs');
$logDirectory = $parameterBag->get('process_manager.log_directory');
$keepLogs = $parameterBag->get('process_manager.keep_logs');
if (!$keepLogs && is_dir($logDirectory)) {
$files = scandir($logDirectory);
foreach ($files as $file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->children()
->scalarNode('driver')->defaultValue(CoreShopResourceBundle::DRIVER_PIMCORE)->end()
->scalarNode('log_directory')->defaultValue('%kernel.logs_dir%')->end()
->booleanNode('keep_logs')->defaultValue(false)->end()
->booleanNode('keep_logs')->defaultValue(true)->end()
->end()
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pimcore.plugin.processmanager.processes = Class.create({
xtype: 'grid',
store: store,
bbar: pimcore.helpers.grid.buildDefaultPagingToolbar(store),
plugins: 'gridfilters',
columns: [
{
text: t('id'),
Expand All @@ -154,12 +155,14 @@ pimcore.plugin.processmanager.processes = Class.create({
{
text: t('name'),
dataIndex: 'name',
width: 300
width: 400,
filter: 'string'
},
{
text: t('processmanager_message'),
dataIndex: 'message',
flex : 1
flex : 1,
filter: 'string'
},
{
text: t('processmanager_started'),
Expand Down Expand Up @@ -273,6 +276,7 @@ pimcore.plugin.processmanager.processes = Class.create({
text : t('processmanager_status'),
width: 100,
dataIndex: 'status',
filter: 'string',
renderer: function (value, metadata, record) {
if (record.data.status != '' && record.data.status != null) {
return t('processmanager_' + record.data.status);
Expand Down

0 comments on commit ad0d232

Please sign in to comment.