tx-cli: command to process received blobs on db to fill transactions table.

skala
Marco Villegas 12 years ago
parent ed5264d2af
commit 6b7cb071a5
  1. 1
      console.php
  2. 35
      src/ChamiloLMS/Command/Transaction/ProcessReceivedEnvelopesCommand.php

@ -78,6 +78,7 @@ $cli->addCommands(
new ChamiloLMS\Command\Template\AsseticDumpCommand(),
new ChamiloLMS\Command\Transaction\ImportToSystemCommand(),
new ChamiloLMS\Command\Transaction\ReceiveCommand(),
new ChamiloLMS\Command\Transaction\ProcessReceivedEnvelopesCommand(),
new ChamiloLMS\Command\Transaction\SendCommand(),
new ChamiloLMS\Command\Transaction\MineduSendCommand(),
new ChamiloLMS\Command\Translation\ExportLanguagesCommand(),

@ -0,0 +1,35 @@
<?php
namespace ChamiloLMS\Command\Transaction;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use ChamiloLMS\Transaction\TransactionLogController;
class ProcessReceivedEnvelopesCommand extends Command
{
protected function configure()
{
$this
->setName('tx:process-received-envelopes')
->setDescription('Process already received envelopes to extract its transactions to the transactions table.')
->addOption('limit', null, InputOption::VALUE_OPTIONAL, 'The maximum number of received envelopes to process in this operation.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$tc = new TransactionLogController();
$limit = (int) $input->getOption('limit');
if ($limit <= 0) {
$limit = 10;
}
$imported_transaction_ids_by_envelope = $tc->importPendingEnvelopes($limit);
$total_transactions = 0;
foreach ($imported_transaction_ids_by_envelope as $envelope_id => $imported_transaction_ids) {
$total_transactions += count($imported_transaction_ids);
}
$output->writeln(sprintf('Imported correctly (%d) transactions from (%d) envelopes to the transactions table.', $total_transactions, count($imported_transaction_ids_by_envelope)));
}
}
Loading…
Cancel
Save