Merge branch 'develop-unstable' into chg-bootstrap-elements
commit
ae5a8eef32
|
@ -11,7 +11,7 @@ use Cake\Console\Command;
|
||||||
use Cake\Console\Arguments;
|
use Cake\Console\Arguments;
|
||||||
use Cake\Console\ConsoleIo;
|
use Cake\Console\ConsoleIo;
|
||||||
use Cake\Console\ConsoleOptionParser;
|
use Cake\Console\ConsoleOptionParser;
|
||||||
use Cake\Filesystem\File;
|
use Cake\Filesystem\Folder;
|
||||||
use Cake\Utility\Hash;
|
use Cake\Utility\Hash;
|
||||||
use Cake\Utility\Text;
|
use Cake\Utility\Text;
|
||||||
use Cake\Validation\Validator;
|
use Cake\Validation\Validator;
|
||||||
|
@ -22,7 +22,7 @@ class SummaryCommand extends Command
|
||||||
{
|
{
|
||||||
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
|
protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
|
||||||
{
|
{
|
||||||
$parser->setDescription('Create a summary for data associated to the passed nationality that has been modified.');
|
$parser->setDescription('Create a summary for data associated to the passed nationality that has been modified. Summaries will be printed out in STDIN and written in individual `txt` files.');
|
||||||
$parser->addArgument('nationality', [
|
$parser->addArgument('nationality', [
|
||||||
'short' => 'n',
|
'short' => 'n',
|
||||||
'help' => 'The organisation nationality.',
|
'help' => 'The organisation nationality.',
|
||||||
|
@ -33,6 +33,11 @@ class SummaryCommand extends Command
|
||||||
'help' => 'The amount of days to look back in the logs',
|
'help' => 'The amount of days to look back in the logs',
|
||||||
'default' => 7
|
'default' => 7
|
||||||
]);
|
]);
|
||||||
|
$parser->addOption('output', [
|
||||||
|
'short' => 'o',
|
||||||
|
'help' => 'The destination folder where to write the files',
|
||||||
|
'default' => '/tmp'
|
||||||
|
]);
|
||||||
return $parser;
|
return $parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,15 +54,16 @@ class SummaryCommand extends Command
|
||||||
}
|
}
|
||||||
foreach ($nationalities as $nationality) {
|
foreach ($nationalities as $nationality) {
|
||||||
$this->io->out(sprintf('Nationality: %s', $nationality));
|
$this->io->out(sprintf('Nationality: %s', $nationality));
|
||||||
$this->_collectChangedForNationality($nationality, $days);
|
$this->_collectChangedForNationality($nationality, $days, $args->getOption('output'));
|
||||||
$this->io->out($io->nl(2));
|
$this->io->out($io->nl(2));
|
||||||
$this->io->hr();
|
$this->io->hr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _collectChangedForNationality($nationality, $days)
|
protected function _collectChangedForNationality($nationality, $days, $folderPath)
|
||||||
{
|
{
|
||||||
$filename = sprintf('/tmp/%s.txt', $nationality);
|
$folderPath = rtrim($folderPath, '/');
|
||||||
|
$filename = sprintf('%s/%s.txt', $folderPath, $nationality);
|
||||||
$file_input = fopen($filename, 'w');
|
$file_input = fopen($filename, 'w');
|
||||||
$organisationIDsForNationality = $this->_fetchOrganisationsForNationality($nationality);
|
$organisationIDsForNationality = $this->_fetchOrganisationsForNationality($nationality);
|
||||||
if (empty($organisationIDsForNationality)) {
|
if (empty($organisationIDsForNationality)) {
|
||||||
|
|
Loading…
Reference in New Issue