Crash fix #70
1 changed files with 32 additions and 20 deletions
|
@ -136,6 +136,10 @@ class MainController extends AppController {
|
||||||
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
$count = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||||
$numClaims = $count->Total;
|
$numClaims = $count->Total;
|
||||||
|
|
||||||
|
$stmt = $conn->execute('SELECT MAX(id) AS MaxId FROM claim');
|
||||||
|
$res = $stmt->fetch(\PDO::FETCH_OBJ);
|
||||||
|
$maxClaimId = $res->MaxId;
|
||||||
|
|
||||||
$numPages = ceil($numClaims / $pageLimit);
|
$numPages = ceil($numClaims / $pageLimit);
|
||||||
if ($page < 1) {
|
if ($page < 1) {
|
||||||
$page = 1;
|
$page = 1;
|
||||||
|
@ -144,8 +148,16 @@ class MainController extends AppController {
|
||||||
$page = $numPages;
|
$page = $numPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
$offset = ($page - 1) * $pageLimit;
|
$startLimitId = $maxClaimId - ($page * $pageLimit);
|
||||||
$claims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->order(['Claims.created_at' => 'DESC'])->offset($offset)->limit($pageLimit)->toArray();
|
$endLimitId = $startLimitId + $pageLimit;
|
||||||
|
if ($endLimitId > $maxClaimId) {
|
||||||
|
$endLimitId = $maxClaimId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$claims = $this->Claims->find()->select($this->Claims)->
|
||||||
|
select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->
|
||||||
|
where(['Claims.id >' => $startLimitId, 'Claims.id <=' => $endLimitId])->
|
||||||
|
order(['Claims.id' => 'DESC'])->toArray();
|
||||||
|
|
||||||
for ($i = 0; $i < count($claims); $i++) {
|
for ($i = 0; $i < count($claims); $i++) {
|
||||||
if ($canConvert && $claims[$i]->fee > 0 && $claims[$i]->fee_currency == 'USD') {
|
if ($canConvert && $claims[$i]->fee > 0 && $claims[$i]->fee_currency == 'USD') {
|
||||||
|
|
Loading…
Reference in a new issue