UpdateSubscriptionsCommand now uses ProgressBar.
This commit is contained in:
parent
a6ac3757b6
commit
5bf20066fa
|
@ -22,7 +22,7 @@ monolog:
|
||||||
console:
|
console:
|
||||||
type: console
|
type: console
|
||||||
verbosity_levels:
|
verbosity_levels:
|
||||||
VERBOSITY_NORMAL: INFO
|
VERBOSITY_NORMAL: WARNING
|
||||||
channels: [!event, !doctrine]
|
channels: [!event, !doctrine]
|
||||||
# uncomment to get logging in your browser
|
# uncomment to get logging in your browser
|
||||||
# you may have to allow bigger header sizes in your Web server configuration
|
# you may have to allow bigger header sizes in your Web server configuration
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Skobkin\Bundle\PointToolsBundle\Repository\UserRepository;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager;
|
use Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
|
use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
@ -51,6 +52,11 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
*/
|
*/
|
||||||
private $subscriptionManager;
|
private $subscriptionManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ProgressBar
|
||||||
|
*/
|
||||||
|
private $progress;
|
||||||
|
|
||||||
|
|
||||||
public function setLogger(LoggerInterface $logger)
|
public function setLogger(LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
|
@ -118,9 +124,14 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->progress = new ProgressBar($output);
|
||||||
|
$this->progress->setFormat('debug');
|
||||||
|
|
||||||
// Beginning transaction for all changes
|
// Beginning transaction for all changes
|
||||||
$this->em->beginTransaction();
|
$this->em->beginTransaction();
|
||||||
|
|
||||||
|
$this->progress->setMessage('Getting service subscribers');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$usersForUpdate = $this->getUsersForUpdate($appUserId);
|
$usersForUpdate = $this->getUsersForUpdate($appUserId);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -136,9 +147,13 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('Processing users subscribers');
|
$this->logger->info('Processing users subscribers');
|
||||||
|
$this->progress->setMessage('Processing users subscribers');
|
||||||
|
$this->progress->start(count($usersForUpdate));
|
||||||
|
|
||||||
$this->updateUsersSubscribers($usersForUpdate);
|
$this->updateUsersSubscribers($usersForUpdate);
|
||||||
|
|
||||||
|
$this->progress->finish();
|
||||||
|
|
||||||
// Flushing all changes at once to database
|
// Flushing all changes at once to database
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
$this->em->commit();
|
$this->em->commit();
|
||||||
|
@ -192,6 +207,8 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->progress->advance();
|
||||||
|
|
||||||
usleep($this->apiDelay);
|
usleep($this->apiDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue