Modify the load warranty serial command to process one file. Add a command to get the number of pending files. Add bash script to call the load warranty serial command. #708
This commit is contained in:
parent
815c25a894
commit
97d058c3d3
4 changed files with 66 additions and 2 deletions
54
src/Command/CountTotalPendingWarrantySerialFilesCommand.php
Normal file
54
src/Command/CountTotalPendingWarrantySerialFilesCommand.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\WarrantySerialQueue;
|
||||
|
||||
class CountTotalPendingWarrantySerialFilesCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('warrantyserial:count')
|
||||
->setDescription('Count number of pending warranty serial files.')
|
||||
->setHelp('Count number of pending warranty serial files.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
$status = 'pending';
|
||||
|
||||
$db = $em->getConnection();
|
||||
|
||||
$ws_query_sql = 'SELECT COUNT(*) AS total FROM warranty_serial_queue
|
||||
WHERE status = :status';
|
||||
|
||||
$ws_query_stmt = $db->prepare($ws_query_sql);
|
||||
$ws_query_stmt->bindValue('status', $status);
|
||||
|
||||
$ws_results = $ws_query_stmt->executeQuery();
|
||||
|
||||
$results = $ws_results->fetchAssociative();
|
||||
|
||||
$output->write($results['total']);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class LoadWarrantySerialCommand extends Command
|
|||
$db = $em->getConnection();
|
||||
|
||||
$ws_query_sql = 'SELECT id, file_serial, file_id, api_user, orig_file_serial FROM warranty_serial_queue
|
||||
WHERE status = :status';
|
||||
WHERE status = :status LIMIT 1';
|
||||
|
||||
$ws_query_stmt = $db->prepare($ws_query_sql);
|
||||
$ws_query_stmt->bindValue('status', $status);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class WarrantySerialLoadLogger
|
|||
$cache_dir = __DIR__ . '/../../var/cache';
|
||||
|
||||
$file = $cache_dir . '/warranty_serial_load_log.tab';
|
||||
error_log('opening file for warranty serial load log - ' . $file);
|
||||
// error_log('opening file for warranty serial load log - ' . $file);
|
||||
|
||||
$fp = fopen($file, 'w');
|
||||
if ($fp === false)
|
||||
|
|
|
|||
10
utils/warranty_serial_load/warranty_serial_load.sh
Executable file
10
utils/warranty_serial_load/warranty_serial_load.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
# get the number fo warranty serial files to process
|
||||
declare -i num_files
|
||||
|
||||
num_files=`/var/www/resq/bin/console warrantyserial:count`
|
||||
|
||||
for (( i = 1; i <= num_files; i++ ))
|
||||
do
|
||||
/usr/bin/php /var/www/resq/bin/console warrantyserial:load
|
||||
done
|
||||
Loading…
Reference in a new issue