This commit is contained in:
2026-03-11 21:48:59 +03:00
parent 980f656a0a
commit 02ad7d83ef
365 changed files with 1 additions and 782 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Bastion\Handlers;
use Openguru\OpenCartFramework\Cache\CacheInterface;
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
class TeleCartPulseStatsHandler
{
private TeleCartEvent $eventModel;
private CacheInterface $cache;
private const CACHE_KEY = 'telecart_pulse_stats';
private const CACHE_TTL = 3600; // 1 час
public function __construct(TeleCartEvent $eventModel, CacheInterface $cache)
{
$this->eventModel = $eventModel;
$this->cache = $cache;
}
public function getStats(): JsonResponse
{
$stats = $this->cache->get(self::CACHE_KEY);
if ($stats === null) {
$stats = $this->eventModel->getStats();
$this->cache->set(self::CACHE_KEY, $stats, self::CACHE_TTL);
}
return new JsonResponse(['data' => $stats]);
}
}