From 15935ec10977aa51cf8990c6c15d853430944bd4 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 28 Oct 2020 15:23:28 +0100 Subject: [PATCH] fix CQ load when fetching more claims for a publishher --- src/Controller/MainController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 3927e99..15a6515 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -219,7 +219,15 @@ class MainController extends AppController { $moreClaims = []; if (isset($claim->publisher) || $claim->claim_type == 1) { // find more claims for the publisher - $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(); + $moreClaimsQuery = $this->Claims->find()->select([ + 'claim_id', 'bid_state', 'price', 'fee', 'fee_currency', 'is_nsfw', 'claim_type', + 'name', 'title', 'description', 'content_type', 'language', 'author', 'license', + 'content_type' + ])->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); + if ($id !== 'f2cf43b86b9d70175dc22dbb9ff7806241d90780') { // prevent ORDER BY for this particular claim + $moreClaimsQuery = $moreClaimsQuery->order(['Claims.fee' => 'DESC', 'RAND()' => 'DESC']); + } + $moreClaims = $moreClaimsQuery->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;