commit
02551e98d7
1 changed files with 32 additions and 20 deletions
|
@ -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,16 @@ 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;
|
||||
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++) {
|
||||
if ($canConvert && $claims[$i]->fee > 0 && $claims[$i]->fee_currency == 'USD') {
|
||||
|
|
Loading…
Reference in a new issue