Using new bind variables in commands.
This commit is contained in:
parent
8c59f656f6
commit
4cc4f50e13
|
@ -22,7 +22,7 @@ class RestoreRemovedUsersCommand extends Command
|
||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private readonly UserRepository $userRepo,
|
private readonly UserRepository $userRepo,
|
||||||
private readonly UserApi $userApi,
|
private readonly UserApi $userApi,
|
||||||
private readonly int $apiDelay,
|
private readonly int $pointApiDelay,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class RestoreRemovedUsersCommand extends Command
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
foreach ($this->userRepo->findBy(['removed' => true]) as $removedUser) {
|
foreach ($this->userRepo->findBy(['removed' => true]) as $removedUser) {
|
||||||
\usleep($this->apiDelay);
|
\usleep($this->pointApiDelay);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$remoteUser = $this->userApi->getUserById($removedUser->getId());
|
$remoteUser = $this->userApi->getUserById($removedUser->getId());
|
||||||
|
|
|
@ -26,8 +26,8 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
private readonly UserRepository $userRepo,
|
private readonly UserRepository $userRepo,
|
||||||
private readonly UserApi $api,
|
private readonly UserApi $api,
|
||||||
private readonly SubscriptionsManager $subscriptionManager,
|
private readonly SubscriptionsManager $subscriptionManager,
|
||||||
private readonly int $apiDelay,
|
private readonly int $pointApiDelay,
|
||||||
private readonly int $appUserId
|
private readonly int $pointAppUserId,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
$progress->start(count($usersForUpdate));
|
$progress->start(count($usersForUpdate));
|
||||||
|
|
||||||
foreach ($usersForUpdate as $user) {
|
foreach ($usersForUpdate as $user) {
|
||||||
usleep($this->apiDelay);
|
usleep($this->pointApiDelay);
|
||||||
|
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
$this->logger->info('Processing @'.$user->getLogin());
|
$this->logger->info('Processing @'.$user->getLogin());
|
||||||
|
@ -155,9 +155,9 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
} else {
|
} else {
|
||||||
/** @var User $serviceUser */
|
/** @var User $serviceUser */
|
||||||
try {
|
try {
|
||||||
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
|
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->pointAppUserId);
|
||||||
} catch (\Exception $e) {
|
} 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;
|
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.');
|
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$serviceUser = $this->api->getUserById($this->appUserId);
|
$serviceUser = $this->api->getUserById($this->pointAppUserId);
|
||||||
} catch (UserNotFoundException $e) {
|
} catch (UserNotFoundException $e) {
|
||||||
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
|
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');
|
$this->logger->info('Getting service subscribers');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$usersForUpdate = $this->api->getUserSubscribersById($this->appUserId);
|
$usersForUpdate = $this->api->getUserSubscribersById($this->pointAppUserId);
|
||||||
} catch (UserNotFoundException $e) {
|
} catch (UserNotFoundException $e) {
|
||||||
$this->logger->critical('Service user deleted or API response is invalid');
|
$this->logger->critical('Service user deleted or API response is invalid');
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ class UpdateUsersPrivacyCommand extends Command
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
private readonly UserRepository $userRepo,
|
private readonly UserRepository $userRepo,
|
||||||
private readonly UserApi $api,
|
private readonly UserApi $api,
|
||||||
private readonly int $apiDelay,
|
private readonly int $pointApiDelay,
|
||||||
private readonly int $appUserId,
|
private readonly int $pointAppUserId,
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class UpdateUsersPrivacyCommand extends Command
|
||||||
$progress->start(count($usersForUpdate));
|
$progress->start(count($usersForUpdate));
|
||||||
|
|
||||||
foreach ($usersForUpdate as $user) {
|
foreach ($usersForUpdate as $user) {
|
||||||
usleep($this->apiDelay);
|
usleep($this->pointApiDelay);
|
||||||
|
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
$this->logger->info('Processing @'.$user->getLogin());
|
$this->logger->info('Processing @'.$user->getLogin());
|
||||||
|
@ -129,9 +129,9 @@ class UpdateUsersPrivacyCommand extends Command
|
||||||
|
|
||||||
/** @var User $serviceUser */
|
/** @var User $serviceUser */
|
||||||
try {
|
try {
|
||||||
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->appUserId);
|
$serviceUser = $this->userRepo->findActiveUserWithSubscribers($this->pointAppUserId);
|
||||||
} catch (\Exception $e) {
|
} 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;
|
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.');
|
$this->logger->warning('Service user not found or marked as removed. Falling back to API.');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$serviceUser = $this->api->getUserById($this->appUserId);
|
$serviceUser = $this->api->getUserById($this->pointAppUserId);
|
||||||
} catch (UserNotFoundException $e) {
|
} catch (UserNotFoundException $e) {
|
||||||
throw new \RuntimeException('Service user not found in the database and could not be retrieved from API.');
|
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');
|
$this->logger->info('Getting service subscribers');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return $this->api->getUserSubscribersById($this->appUserId);
|
return $this->api->getUserSubscribersById($this->pointAppUserId);
|
||||||
} catch (UserNotFoundException $e) {
|
} catch (UserNotFoundException $e) {
|
||||||
$this->logger->critical('Service user deleted or API response is invalid');
|
$this->logger->critical('Service user deleted or API response is invalid');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue