Skip to content

Commit

Permalink
commandlog/show command: made deep search optional with param
Browse files Browse the repository at this point in the history
  • Loading branch information
danigargar committed Feb 19, 2024
1 parent 6d262b3 commit 4409cf9
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CommandlogBundle/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ protected function configure()
null,
InputOption::VALUE_NONE,
'Show detailed command payload?'
);
)
->addOption(
'deep',
'd',
InputOption::VALUE_NONE,
'Deep search including mass updates, deletes, etc.'
)
;
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand All @@ -75,6 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$entity,
$id,
$output,
$input->getOption('deep'),
$input->getOption('detailed')
);

Expand Down Expand Up @@ -118,12 +126,17 @@ private function findEntityByTable(string $table)
throw new \Exception('Table does not exist or its not loggable');
}

private function getEntityChangelog(string $entity, string $id, OutputInterface $output, bool $detailed)
private function getEntityChangelog(string $entity, string $id, OutputInterface $output, bool $deepSearch, bool $detailed)
{
$deepSearchSql = $deepSearch
? ' OR (entityId = 0 AND data REGEXP \':data\')'
: '';

$queryStr =
'select id, commandId, data, createdOn from Changelog where entity = :entity'
. ' and (entityId = \':entityId\' OR (entityId = 0 and data REGEXP \':data\'))'
. ' order by createdOn asc, microtime asc';
. ' and (entityId = \':entityId\''
. $deepSearchSql
. ') order by createdOn asc, microtime asc';

$replacements = [
':entityId' => $id,
Expand Down

0 comments on commit 4409cf9

Please sign in to comment.