mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
feat: use domainPurchase to get stats
This commit is contained in:
parent
4f6b8d5b97
commit
29db54ad17
@ -95,7 +95,7 @@ export default function StatisticsPage() {
|
||||
<Statistic
|
||||
loading={stats === undefined}
|
||||
title={t`Success rate`}
|
||||
value={successRate === undefined ? '-' : successRate * 100}
|
||||
value={successRate === undefined ? '-' : (successRate * 100).toFixed(2)}
|
||||
suffix='%'
|
||||
valueStyle={{color: successRate === undefined ? 'grey' : successRate >= 0.5 ? 'darkgreen' : 'orange'}}
|
||||
/>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Statistics;
|
||||
use App\Repository\DomainPurchaseRepository;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Repository\WatchlistRepository;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
@ -16,6 +17,7 @@ class StatisticsController extends AbstractController
|
||||
private readonly CacheItemPoolInterface $pool,
|
||||
private readonly DomainRepository $domainRepository,
|
||||
private readonly WatchlistRepository $watchlistRepository,
|
||||
private readonly DomainPurchaseRepository $domainPurchaseRepository,
|
||||
private readonly KernelInterface $kernel,
|
||||
) {
|
||||
}
|
||||
@ -29,8 +31,12 @@ class StatisticsController extends AbstractController
|
||||
|
||||
$stats
|
||||
->setRdapQueries($this->pool->getItem('stats.rdap_queries.count')->get() ?? 0)
|
||||
->setDomainPurchased($this->pool->getItem('stats.domain.purchased')->get() ?? 0)
|
||||
->setDomainPurchaseFailed($this->pool->getItem('stats.domain.purchase.failed')->get() ?? 0)
|
||||
->setDomainPurchased(
|
||||
$this->getCachedItem('stats.domain.purchase', fn () => $this->domainPurchaseRepository->count())
|
||||
)
|
||||
->setDomainPurchaseFailed(
|
||||
$this->getCachedItem('stats.domain.purchase.failed', fn () => $this->domainPurchaseRepository->countFailDomainPurchase())
|
||||
)
|
||||
->setAlertSent($this->pool->getItem('stats.alert.sent')->get() ?? 0)
|
||||
|
||||
->setDomainTracked(
|
||||
|
||||
@ -109,7 +109,6 @@ final readonly class OrderDomainHandler
|
||||
'provider' => $connector->getProvider()->value,
|
||||
]);
|
||||
|
||||
$this->statService->incrementStat('stats.domain.purchased');
|
||||
if ($this->influxdbEnabled) {
|
||||
$this->influxdbService->addDomainOrderPoint($connector, $domain, true);
|
||||
}
|
||||
@ -138,7 +137,6 @@ final readonly class OrderDomainHandler
|
||||
'provider' => $connector->getProvider()->value,
|
||||
]);
|
||||
|
||||
$this->statService->incrementStat('stats.domain.purchase.failed');
|
||||
if ($this->influxdbEnabled) {
|
||||
$this->influxdbService->addDomainOrderPoint($connector, $domain, false);
|
||||
}
|
||||
|
||||
@ -16,28 +16,19 @@ class DomainPurchaseRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, DomainPurchase::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return DomainPurchase[] Returns an array of DomainPurchase objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('d')
|
||||
// ->andWhere('d.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('d.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
public function countSuccessDomainPurchase(): int
|
||||
{
|
||||
return $this->createQueryBuilder('dp')
|
||||
->select('COUNT(*)')
|
||||
->where('dp.domainOrderedAt != NULL')
|
||||
->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
// public function findOneBySomeField($value): ?DomainPurchase
|
||||
// {
|
||||
// return $this->createQueryBuilder('d')
|
||||
// ->andWhere('d.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
public function countFailDomainPurchase(): int
|
||||
{
|
||||
return $this->createQueryBuilder('dp')
|
||||
->select('COUNT(*)')
|
||||
->where('dp.domainOrderedAt == NULL')
|
||||
->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user