From 976436285524da67b54d8c631852b0e3c7f9e77c Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sun, 10 Nov 2019 15:13:08 +0100 Subject: [PATCH] Added constants and new function for LBRY price display --- src/Controller/MainController.php | 4 ++-- src/View/Helper/AmountHelper.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 59c8188..0df6abe 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -175,7 +175,7 @@ class MainController extends AppController { } if ($canConvert && $claim->fee > 0 && $claim->fee_currency == 'USD') { - $claim->price = $claim->fee / $priceInfo->price; + $claim->price = ($claim->fee / 100) / $priceInfo->price; } if (isset($claim->Stream)) { @@ -194,7 +194,7 @@ class MainController extends AppController { $moreClaims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_type' => 1, 'Claims.id <>' => $claim->id, 'Claims.publisher_id' => isset($claim->publisher) ? $claim->publisher_id : $claim->claim_id])->limit(9)->order(['Claims.fee' => 'DESC', 'RAND()' => 'DESC'])->toArray(); for ($i = 0; $i < count($moreClaims); $i++) { if ($canConvert && $moreClaims[$i]->fee > 0 && $moreClaims[$i]->fee_currency == 'USD') { - $moreClaims[$i]->price = $moreClaims[$i]->fee / $priceInfo->price; + $moreClaims[$i]->price = ($moreClaims[$i]->fee / 100) / $priceInfo->price; } if (isset($moreClaims[$i]->Stream)) { diff --git a/src/View/Helper/AmountHelper.php b/src/View/Helper/AmountHelper.php index 75505b3..55df850 100644 --- a/src/View/Helper/AmountHelper.php +++ b/src/View/Helper/AmountHelper.php @@ -5,7 +5,7 @@ namespace App\View\Helper; use Cake\View\Helper; class AmountHelper extends Helper { - const DEWIES_DIVIDER = 100000000; + const DECIMAL_DIVIDER = 100000000; public function format($value, $thousandsSeparator = ',') { $value = number_format($value, 8, '.', $thousandsSeparator); @@ -24,7 +24,7 @@ class AmountHelper extends Helper { } public function formatLbryCurrency($value, $thousandsSeparator = ",") { - return formatCurrency($value / DEWIES_DIVIDER); + return $this->formatCurrency($value / AmountHelper::DECIMAL_DIVIDER); } public function formatCurrency($value, $thousandsSeparator = ',') {