diff --git a/src/Command/CountTotalPendingWarrantySerialFilesCommand.php b/src/Command/CountTotalPendingWarrantySerialFilesCommand.php new file mode 100644 index 00000000..2ff96d5b --- /dev/null +++ b/src/Command/CountTotalPendingWarrantySerialFilesCommand.php @@ -0,0 +1,54 @@ +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; + } +} diff --git a/src/Command/LoadWarrantySerialCommand.php b/src/Command/LoadWarrantySerialCommand.php index f7bd5797..6dfe53d8 100644 --- a/src/Command/LoadWarrantySerialCommand.php +++ b/src/Command/LoadWarrantySerialCommand.php @@ -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); diff --git a/src/Service/WarrantySerialLoadLogger.php b/src/Service/WarrantySerialLoadLogger.php index 904a6535..b66b4db9 100644 --- a/src/Service/WarrantySerialLoadLogger.php +++ b/src/Service/WarrantySerialLoadLogger.php @@ -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) diff --git a/utils/warranty_serial_load/warranty_serial_load.sh b/utils/warranty_serial_load/warranty_serial_load.sh new file mode 100755 index 00000000..af79f1af --- /dev/null +++ b/utils/warranty_serial_load/warranty_serial_load.sh @@ -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