Skip to content

Firefly III: a personal finances manager

Add some debug info.

James Coleb58cde5431d5
diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php
index 181f9fd607..79061b6a99 100644
--- a/app/Http/Controllers/Account/IndexController.php
+++ b/app/Http/Controllers/Account/IndexController.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account;
use Carbon\Carbon;
+use Exception;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -32,7 +33,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;
-use Exception;
+use Log;
/**
*
@@ -41,8 +42,8 @@ use Exception;
class IndexController extends Controller
{
use BasicDataSupport;
- /** @var AccountRepositoryInterface The account repository */
- private $repository;
+
+ private AccountRepositoryInterface $repository;
/**
* IndexController constructor.
@@ -122,32 +123,31 @@ class IndexController extends Controller
* @param Request $request
* @param string $objectType
*
- * @throws Exception
* @return Factory|View
+ * @throws Exception
*/
public function index(Request $request, string $objectType)
{
- // reset account order:
-
+ Log::debug(sprintf('Now at %s', __METHOD__));
$objectType = $objectType ?? 'asset';
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
if (1 === random_int(0, 20)) {
+ Log::debug('Will reset order.');
$this->repository->resetAccountOrder($types);
}
$collection = $this->repository->getActiveAccountsByType($types);
-
-
-
$total = $collection->count();
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count();
+ Log::debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count()));
+
unset($collection);
/** @var Carbon $start */
$start = clone session('start', Carbon::now()->startOfMonth());
@@ -174,9 +174,14 @@ class IndexController extends Controller
}
);
// make paginator:
+ Log::debug(sprintf('Count of accounts before LAP: %d', $accounts->count()));
+ /** @var LengthAwarePaginator $accounts */
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
$accounts->setPath(route('accounts.index', [$objectType]));
+ Log::debug(sprintf('Count of accounts after LAP (1): %d', $accounts->count()));
+ Log::debug(sprintf('Count of accounts after LAP (2): %d', $accounts->getCollection()->count()));
+
return view('accounts.index', compact('objectType', 'inactiveCount', 'subTitleIcon', 'subTitle', 'page', 'accounts'));
}