Improved index query

This commit is contained in:
marcdeb1 2018-12-21 13:55:59 +01:00
parent 4e0eeab3d1
commit 3569fdb4ff
2 changed files with 5 additions and 10 deletions

View file

@ -102,13 +102,7 @@ class MainController extends AppController {
$hashRate = $this->_formatHashRate($this->_gethashrate()); $hashRate = $this->_formatHashRate($this->_gethashrate());
// recent claims // recent claims
$claims = $this->Claims->find()->select(['transaction_hash_id', 'name', 'vout', 'claim_id', 'claim_type', 'author', 'title', 'description', 'content_type', 'is_nsfw', 'language', 'thumbnail_url', 'created_at', 'publisher_id'])-> $claims = $this->Claims->find()->distinct(['Claims.claim_id'])->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->order(['Claims.created_at' => 'DESC'])->limit(5)->toArray();
distinct(['Claims.claim_id'])->order(['Claims.created_at' => 'DESC'])->limit(5)->toArray();
foreach($claims as $claim) {
$publisher = $this->Claims->find()->select(['name'])->where(['claim_id' => $claim->publisher_id])->first();
$claim->publisher = $publisher;
}
$this->set('recentBlocks', $blocks); $this->set('recentBlocks', $blocks);
$this->set('recentClaims', $claims); $this->set('recentClaims', $claims);
@ -227,6 +221,7 @@ class MainController extends AppController {
} }
$transactions = $this->Transactions->find()->select(['Transactions.id', 'Transactions.hash', 'Transactions.input_count', 'Transactions.output_count', 'Transactions.transaction_time', 'Transactions.created_at'])->select(['value' => 'sum(O.value)'])->leftJoin(['O' => 'output'], ['O.transaction_id = Transactions.id'])->order(['Transactions.created_at' => 'desc'])->limit(10)->toArray(); $transactions = $this->Transactions->find()->select(['Transactions.id', 'Transactions.hash', 'Transactions.input_count', 'Transactions.output_count', 'Transactions.transaction_time', 'Transactions.created_at'])->select(['value' => 'sum(O.value)'])->leftJoin(['O' => 'output'], ['O.transaction_id = Transactions.id'])->order(['Transactions.created_at' => 'desc'])->limit(10)->toArray();
$this->set('blocks', $blocks); $this->set('blocks', $blocks);
$this->set('txs', $transactions); $this->set('txs', $transactions);
} }

View file

@ -189,9 +189,9 @@
$autoThumbText = $claim->getAutoThumbText(); $autoThumbText = $claim->getAutoThumbText();
$link = $claim->name; $link = $claim->name;
$rawLink = $claim->name; $rawLink = $claim->name;
if (isset($claim->publisher->name)) { if (isset($claim->publisher)) {
$link = urlencode($claim->publisher->name) . '/' . $link; $link = urlencode($claim->publisher) . '/' . $link;
$rawLink = $claim->publisher->name . '/' . $link; $rawLink = $claim->publisher . '/' . $link;
} }
$link = 'lbry://' . $link; $link = 'lbry://' . $link;
$rawLink = 'lbry://' . $rawLink; $rawLink = 'lbry://' . $rawLink;