diff --git a/community_server/src/Controller/AppRequestsController.php b/community_server/src/Controller/AppRequestsController.php index 018e0af49..43242af84 100644 --- a/community_server/src/Controller/AppRequestsController.php +++ b/community_server/src/Controller/AppRequestsController.php @@ -25,7 +25,7 @@ class AppRequestsController extends AppController $this->loadComponent('GradidoNumber'); //$this->loadComponent('JsonRpcRequestClient'); //$this->Auth->allow(['add', 'edit']); - $this->Auth->allow(['index', 'sendCoins', 'createCoins', 'getBalance', 'listTransactions']); + $this->Auth->allow(['index', 'sendCoins', 'createCoins', 'getBalance', 'listTransactions', 'getDecayStartBlock']); } @@ -335,11 +335,18 @@ class AppRequestsController extends AppController $limit = $count; $offset = 0; + $skip_first_transaction = false; if($page == 1) { $limit--; } else { $offset = (( $page - 1 ) * $count) - 1; } + if($offset) { + // move cursor one step backwards to able to load one transaction previous last which will be shown for decay calculation + $offset--; + $limit++; + $skip_first_transaction = true; + } $stateUserTransactionsQuery = $stateUserTransactionsTable ->find() @@ -362,7 +369,7 @@ class AppRequestsController extends AppController $transactions_from_db = array_reverse($transactions_from_db); } - $transactions = $transactionsTable->listTransactionsHumanReadable($transactions_from_db, $user, $decay); + $transactions = $transactionsTable->listTransactionsHumanReadable($transactions_from_db, $user, $decay, $skip_first_transaction); if($orderDirection == 'DESC') { $transactions = array_reverse($transactions); diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 3a7555ba8..925f6f31e 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -133,7 +133,7 @@ class TransactionsTable extends Table } - public function listTransactionsHumanReadable($stateUserTransactions, array $user, $decay = true) + public function listTransactionsHumanReadable($stateUserTransactions, array $user, $decay = true, $skip_first_transaction = false) { $stateUsersTable = TableRegistry::getTableLocator()->get('StateUsers'); @@ -267,8 +267,9 @@ class TransactionsTable extends Table $final_transaction['name'] = $otherUser->first_name . ' ' . $otherUser->last_name; $final_transaction['email'] = $otherUser->email; } - - $final_transactions[] = $final_transaction; + if($i > 0 || !$skip_first_transaction) { + $final_transactions[] = $final_transaction; + } if($i == $stateUserTransactionsCount-1 && $decay) { $now = new FrozenTime();