Using new bind variables in commands.

This commit is contained in:
Alexey Skobkin 2023-03-26 17:07:00 +03:00
parent 8c59f656f6
commit 4cc4f50e13
No known key found for this signature in database
GPG Key ID: 5D5CEF6F221278E7
3 changed files with 26 additions and 26 deletions

View File

@ -18,11 +18,11 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class RestoreRemovedUsersCommand extends Command
{
public function __construct(
private readonly LoggerInterface $logger,
private readonly LoggerInterface $logger,
private readonly EntityManagerInterface $em,
private readonly UserRepository $userRepo,
private readonly UserApi $userApi,
private readonly int $apiDelay,
private readonly UserRepository $userRepo,
private readonly UserApi $userApi,
private readonly int $pointApiDelay,
) {
parent::__construct();
}
@ -32,7 +32,7 @@ class RestoreRemovedUsersCommand extends Command
$io = new SymfonyStyle($input, $output);
foreach ($this->userRepo->findBy(['removed' => true]) as $removedUser) {
\usleep($this->apiDelay);
\usleep($this->pointApiDelay);
try {
$remoteUser = $this->userApi->getUserById($removedUser->getId());

View File

@ -22,12 +22,12 @@ class UpdateSubscriptionsCommand extends Command
{
public function __construct(
private readonly EntityManagerInterface $em,
private readonly LoggerInterface $logger,
private readonly UserRepository $userRepo,
private readonly UserApi $api,
private readonly SubscriptionsManager $subscriptionManager,
private readonly int $apiDelay,
private readonly int $appUserId
private readonly LoggerInterface $logger,
private readonly UserRepository $userRepo,
private readonly UserApi $api,
private readonly SubscriptionsManager $subscriptionManager,
private readonly int $pointApiDelay,
private readonly int $pointAppUserId,
) {
parent::__construct();
}
@ -81,7 +81,7 @@ class UpdateSubscriptionsCommand extends Command
$progress->start(count($usersForUpdate));
foreach ($usersForUpdate as $user) {
usleep($this->apiDelay);
usleep($this->pointApiDelay);
$progress->advance();
$this->logger->info('Processing @'.$user->getLogin());
@ -155,9 +155,9 @@ class UpdateSubscriptionsCommand extends Command
} else {
/** @var User $serviceUser */
try {
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->pointAppUserId);
} catch (\Exception $e) {
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->appUserId]);
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->pointAppUserId]);
throw $e;
}
@ -166,7 +166,7 @@ class UpdateSubscriptionsCommand extends Command
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
try {
$serviceUser = $this->api->getUserById($this->appUserId);
$serviceUser = $this->api->getUserById($this->pointAppUserId);
} catch (UserNotFoundException $e) {
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
}
@ -175,7 +175,7 @@ class UpdateSubscriptionsCommand extends Command
$this->logger->info('Getting service subscribers');
try {
$usersForUpdate = $this->api->getUserSubscribersById($this->appUserId);
$usersForUpdate = $this->api->getUserSubscribersById($this->pointAppUserId);
} catch (UserNotFoundException $e) {
$this->logger->critical('Service user deleted or API response is invalid');

View File

@ -23,11 +23,11 @@ class UpdateUsersPrivacyCommand extends Command
{
public function __construct(
private readonly EntityManagerInterface $em,
private readonly LoggerInterface $logger,
private readonly UserRepository $userRepo,
private readonly UserApi $api,
private readonly int $apiDelay,
private readonly int $appUserId,
private readonly LoggerInterface $logger,
private readonly UserRepository $userRepo,
private readonly UserApi $api,
private readonly int $pointApiDelay,
private readonly int $pointAppUserId,
) {
parent::__construct();
}
@ -66,7 +66,7 @@ class UpdateUsersPrivacyCommand extends Command
$progress->start(count($usersForUpdate));
foreach ($usersForUpdate as $user) {
usleep($this->apiDelay);
usleep($this->pointApiDelay);
$progress->advance();
$this->logger->info('Processing @'.$user->getLogin());
@ -129,9 +129,9 @@ class UpdateUsersPrivacyCommand extends Command
/** @var User $serviceUser */
try {
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->pointAppUserId);
} catch (\Exception $e) {
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->appUserId]);
$this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $this->pointAppUserId]);
throw $e;
}
@ -140,7 +140,7 @@ class UpdateUsersPrivacyCommand extends Command
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
try {
$serviceUser = $this->api->getUserById($this->appUserId);
$serviceUser = $this->api->getUserById($this->pointAppUserId);
} catch (UserNotFoundException $e) {
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
}
@ -149,7 +149,7 @@ class UpdateUsersPrivacyCommand extends Command
$this->logger->info('Getting service subscribers');
try {
return $this->api->getUserSubscribersById($this->appUserId);
return $this->api->getUserSubscribersById($this->pointAppUserId);
} catch (UserNotFoundException $e) {
$this->logger->critical('Service user deleted or API response is invalid');