chart fixed

This commit is contained in:
2026-06-17 12:12:35 +03:30
parent 3e70b1ab43
commit c3b868c6b5
9 changed files with 293 additions and 22 deletions
+13 -3
View File
@@ -3,6 +3,7 @@
namespace App\Services;
use App\Http\Controllers\Site\ReportController;
use App\Models\PriceSyncLog;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
@@ -12,13 +13,15 @@ class LivePriceTickService
{
private const LOCK_SECONDS = 25;
public function tick(): void
public function tick(): ?PriceSyncLog
{
$lock = Cache::lock('prices:tick', self::LOCK_SECONDS);
if (! $lock->get()) {
return;
return null;
}
$syncLog = null;
try {
$config = app(ConfigService::class);
$sync = app(ProductPriceSyncService::class);
@@ -73,15 +76,22 @@ class LivePriceTickService
->whereNotNull('reading_method')
->count();
app(PriceSyncLogService::class)->recordTick($source, $sourceUrl, $liquidGold, $activeProducts);
$syncLog = app(PriceSyncLogService::class)->recordTick($source, $sourceUrl, $liquidGold, $activeProducts);
if ($payload !== []) {
app(PriceSnapshotService::class)->recordTick($payload);
}
app(LivePriceCacheService::class)->markTick();
$broadcastPayload = $payload;
dispatch(function () use ($broadcastPayload) {
app(PriceBroadcastService::class)->broadcastAfterPriceUpdate($broadcastPayload);
})->afterResponse();
} finally {
$lock->release();
}
return $syncLog;
}
}