fix channel price bug
This commit is contained in:
@@ -141,7 +141,20 @@ class ReportController extends Controller
|
||||
$payload['last_historical'] = app(ProductDisplayPriceService::class)->resolveHistoricalBasePrice();
|
||||
app(ProductDisplayPriceService::class)->cacheLivePricePayload($payload);
|
||||
|
||||
if ($saveFullCache || request()->boolean('force_refresh')) {
|
||||
$isFreshPrice = $saveFullCache || request()->boolean('force_refresh');
|
||||
|
||||
// ارسال قیمت به کانال فقط روی «لحظهٔ تغییر قیمت» = مسیر force_refresh (همان چیزی که سرورِ
|
||||
// حساس به قیمت صدا میزند و مبنای برادکست SSE است) — نه هر pulling عادی که کش برمیگرداند.
|
||||
// بعد از پاسخ اجرا میشود تا تاخیری برای فراخوان نباشد. در کنسول صدا نمیزنیم چون tick()
|
||||
// خودش مستقیماً broadcastIfEligible را اجرا میکند و afterResponse در دیمن اجرا نمیشود.
|
||||
// خودِ سرویس با price_channel_min_seconds و تشخیص تغییر قیمت گیت میکند.
|
||||
if ($isFreshPrice && (int) ($payload['price'] ?? 0) > 0 && ! app()->runningInConsole()) {
|
||||
dispatch(function () {
|
||||
app(\App\Services\PriceChannelBroadcastService::class)->broadcastIfEligible();
|
||||
})->afterResponse();
|
||||
}
|
||||
|
||||
if ($isFreshPrice) {
|
||||
$cache = app(LivePriceCacheService::class);
|
||||
$cache->markTick();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user