added ons
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Services\AssetSummaryService;
|
||||
use App\Services\LivePriceCacheService;
|
||||
use App\Services\PriceBroadcastService;
|
||||
use App\Services\PriceStreamService;
|
||||
use App\Services\ZaarboxPriceService;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
@@ -47,7 +48,7 @@ class PriceStreamController extends Controller
|
||||
$cache = app(LivePriceCacheService::class);
|
||||
$last = $cache->get() ?? $cache->buildFromDatabase();
|
||||
if (is_array($last) && $last !== []) {
|
||||
$send('last', $last);
|
||||
$send('last', app(ZaarboxPriceService::class)->attachGoldOunceToPayload($last));
|
||||
}
|
||||
|
||||
$list = app(PriceBroadcastService::class)->buildListPayload(false);
|
||||
|
||||
@@ -167,25 +167,7 @@ class ReportController extends Controller
|
||||
|
||||
protected function resolveGoldOuncePayload(): ?array
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
if (! $config->getBool('show_gold_ounce_price', false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$zaarbox = app(ZaarboxPriceService::class);
|
||||
if (! $zaarbox->hasApiUrlConfigured()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ounce = $zaarbox->fetchOuncePrice();
|
||||
if (($ounce['price'] ?? 0) <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'price' => (int) $ounce['price'],
|
||||
'label' => trim((string) ($ounce['name'] ?? 'انس طلا')) ?: 'انس طلا',
|
||||
];
|
||||
return app(ZaarboxPriceService::class)->clientGoldOuncePayload();
|
||||
}
|
||||
|
||||
public function lastPrice(Request $request)
|
||||
@@ -197,6 +179,8 @@ class ReportController extends Controller
|
||||
if (! $forceRefresh) {
|
||||
$cached = $cache->get();
|
||||
if ($cached !== null) {
|
||||
$cached['gold_ounce'] = $this->resolveGoldOuncePayload();
|
||||
|
||||
return $cached;
|
||||
}
|
||||
|
||||
@@ -204,7 +188,7 @@ class ReportController extends Controller
|
||||
if ($cache->hasRecentTick()) {
|
||||
$dbBuilt = $cache->buildFromDatabase();
|
||||
if (($dbBuilt['price'] ?? 0) > 0) {
|
||||
return $cache->put($dbBuilt);
|
||||
return $this->appendUpPrices($dbBuilt, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user