fix zero price on homepage

This commit is contained in:
Akinwale Ariwodola 2017-08-14 21:02:12 +01:00
parent 32c7118cf8
commit f85b9982e2

View file

@ -53,7 +53,7 @@ class MainController extends AppController {
$lastPriceDt = new \DateTime($priceInfo->time); $lastPriceDt = new \DateTime($priceInfo->time);
$diff = $now->diff($lastPriceDt); $diff = $now->diff($lastPriceDt);
$diffMinutes = $diff->i; $diffMinutes = $diff->i;
if ($diffMinutes >= 15) { // 15 minutes if ($diffMinutes >= 15 || $priceInfo->price == 0) { // 15 minutes (or if the price is 0)
$shouldRefreshPrice = true; $shouldRefreshPrice = true;
} }
} }
@ -68,6 +68,7 @@ class MainController extends AppController {
$lbcPrice = 0; $lbcPrice = 0;
if (isset($blckjson->USD)) { if (isset($blckjson->USD)) {
$lbcPrice = $onelbc * $blckjson->USD->buy; $lbcPrice = $onelbc * $blckjson->USD->buy;
if ($lbcPrice > 0) {
$priceInfo->price = number_format($lbcPrice, 2, '.', ''); $priceInfo->price = number_format($lbcPrice, 2, '.', '');
$priceInfo->time = $now->format('c'); $priceInfo->time = $now->format('c');
if ($this->redis) { if ($this->redis) {
@ -76,6 +77,7 @@ class MainController extends AppController {
} }
} }
} }
}
$lbcUsdPrice = (isset($priceInfo->price) && ($priceInfo->price > 0)) ? '$' . $priceInfo->price : 'N/A'; $lbcUsdPrice = (isset($priceInfo->price) && ($priceInfo->price > 0)) ? '$' . $priceInfo->price : 'N/A';
return $lbcUsdPrice; return $lbcUsdPrice;