Crash fix #70

Merged
akinwale merged 2 commits from crash-fix into master 2019-10-21 17:41:59 +02:00
Showing only changes of commit c18431394c - Show all commits

View file

@ -136,6 +136,10 @@ class MainController extends AppController {
$count = $stmt->fetch(\PDO::FETCH_OBJ);
$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);
if ($page < 1) {
$page = 1;
@ -144,8 +148,13 @@ class MainController extends AppController {
$page = $numPages;
}
$offset = ($page - 1) * $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();
$startLimitId = $maxClaimId - ($page * $pageLimit);
$endLimitId = $startLimitId + $pageLimit;
$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++) {
if ($canConvert && $claims[$i]->fee > 0 && $claims[$i]->fee_currency == 'USD') {