refactor: create StatService

This commit is contained in:
Maël Gangloff
2024-08-25 03:31:09 +02:00
parent 4bb3ba7765
commit 0e1658f6fe
4 changed files with 35 additions and 24 deletions

View File

@@ -5,7 +5,6 @@ namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\Controller\StatisticsController;
use Psr\Cache\CacheItemPoolInterface;
#[ApiResource(
operations: [
@@ -28,19 +27,6 @@ class Statistics
private ?int $domainTracked = null;
private ?int $domainCountTotal = null;
public static function updateRDAPQueriesStat(CacheItemPoolInterface $pool, string $key): bool
{
try {
$item = $pool->getItem($key);
$item->set(($item->get() ?? 0) + 1);
return $pool->save($item);
} catch (\Throwable) {
}
return false;
}
public function getRdapQueries(): ?int
{
return $this->rdapQueries;