mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: create StatService
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Config\TriggerAction;
|
||||
use App\Config\WebhookScheme;
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\DomainEvent;
|
||||
use App\Entity\Statistics;
|
||||
use App\Entity\WatchList;
|
||||
use App\Entity\WatchListTrigger;
|
||||
use App\Message\ProcessDomainTrigger;
|
||||
@@ -16,6 +15,7 @@ use App\Notifier\DomainOrderNotification;
|
||||
use App\Notifier\DomainUpdateNotification;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Repository\WatchListRepository;
|
||||
use App\Service\StatService;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
@@ -44,7 +44,8 @@ final readonly class ProcessDomainTriggerHandler
|
||||
private LoggerInterface $logger,
|
||||
private HttpClientInterface $client,
|
||||
private MailerInterface $mailer,
|
||||
private CacheItemPoolInterface $cacheItemPool
|
||||
private CacheItemPoolInterface $cacheItemPool,
|
||||
private StatService $statService
|
||||
) {
|
||||
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
|
||||
}
|
||||
@@ -86,7 +87,7 @@ final readonly class ProcessDomainTriggerHandler
|
||||
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
|
||||
$this->sendChatNotification($watchList, $notification);
|
||||
|
||||
Statistics::updateRDAPQueriesStat($this->cacheItemPool, 'stats.domain.purchased');
|
||||
$this->statService->incrementStat('stats.domain.purchased');
|
||||
} catch (\Throwable) {
|
||||
$this->logger->warning('Unable to complete purchase. An error message is sent to user {username}.', [
|
||||
'username' => $watchList->getUser()->getUserIdentifier(),
|
||||
@@ -96,7 +97,7 @@ final readonly class ProcessDomainTriggerHandler
|
||||
$this->mailer->send($notification->asEmailMessage(new Recipient($watchList->getUser()->getEmail()))->getMessage());
|
||||
$this->sendChatNotification($watchList, $notification);
|
||||
|
||||
Statistics::updateRDAPQueriesStat($this->cacheItemPool, 'stats.domain.purchase.failed');
|
||||
$this->statService->incrementStat('stats.domain.purchase.failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ final readonly class ProcessDomainTriggerHandler
|
||||
$this->sendChatNotification($watchList, $notification);
|
||||
}
|
||||
|
||||
Statistics::updateRDAPQueriesStat($this->cacheItemPool, 'stats.alert.sent');
|
||||
$this->statService->incrementStat('stats.alert.sent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user