decay only with first page, ensure that the limit is kept

This commit is contained in:
Dario Rekowski on RockPI 2021-06-29 09:56:23 +00:00
parent 999a49c41f
commit 4a68dd3c7a
2 changed files with 15 additions and 4 deletions

View File

@ -333,16 +333,27 @@ class AppRequestsController extends AppController
$this->addAdminError('StateBalancesController', 'overview', $gdtEntries, $user['id'] ? $user['id'] : 0);
}
$limit = $count;
$offset = 0;
if($page == 1) {
$limit--;
} else {
$offset = (( $page - 1 ) * $count) - 1;
}
$stateUserTransactionsQuery = $stateUserTransactionsTable
->find()
->where(['state_user_id' => $user['id']])
->order(['balance_date' => $orderDirection])
->contain([])
->limit($count)
->page($page)
->limit($limit)
//->page($page)
->offset($offset)
;
$decay = true;
if($page > 1) {
$decay = false;
}
$transactions = [];
$transactions_from_db = $stateUserTransactionsQuery->toArray();

View File

@ -185,7 +185,7 @@ class TransactionsTable extends Table
if($i > 0 ) {
$prev = $stateUserTransactions[$i-1];
}
if($prev && $decay == true)
if($prev)
{
if($prev->balance > 0) {
$current = $su_transaction;
@ -252,7 +252,7 @@ class TransactionsTable extends Table
$final_transactions[] = $final_transaction;
if($i == $stateUserTransactionsCount-1 && $decay == true) {
if($i == $stateUserTransactionsCount-1 && $decay) {
$now = new FrozenTime();
$calculated_decay = $stateBalancesTable->calculateDecay(
$su_transaction->balance,