mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Add some debug info.
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Account;
|
namespace FireflyIII\Http\Controllers\Account;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@@ -32,7 +33,7 @@ use Illuminate\Contracts\View\Factory;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Exception;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -41,8 +42,8 @@ use Exception;
|
|||||||
class IndexController extends Controller
|
class IndexController extends Controller
|
||||||
{
|
{
|
||||||
use BasicDataSupport;
|
use BasicDataSupport;
|
||||||
/** @var AccountRepositoryInterface The account repository */
|
|
||||||
private $repository;
|
private AccountRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexController constructor.
|
* IndexController constructor.
|
||||||
@@ -122,32 +123,31 @@ class IndexController extends Controller
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $objectType
|
* @param string $objectType
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, string $objectType)
|
public function index(Request $request, string $objectType)
|
||||||
{
|
{
|
||||||
// reset account order:
|
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||||
|
|
||||||
$objectType = $objectType ?? 'asset';
|
$objectType = $objectType ?? 'asset';
|
||||||
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
|
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
|
||||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||||
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
||||||
|
|
||||||
if (1 === random_int(0, 20)) {
|
if (1 === random_int(0, 20)) {
|
||||||
|
Log::debug('Will reset order.');
|
||||||
$this->repository->resetAccountOrder($types);
|
$this->repository->resetAccountOrder($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = $this->repository->getActiveAccountsByType($types);
|
$collection = $this->repository->getActiveAccountsByType($types);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$total = $collection->count();
|
$total = $collection->count();
|
||||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||||
$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count();
|
$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count();
|
||||||
|
|
||||||
|
Log::debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count()));
|
||||||
|
|
||||||
unset($collection);
|
unset($collection);
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
@@ -174,9 +174,14 @@ class IndexController extends Controller
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
// make paginator:
|
// make paginator:
|
||||||
|
Log::debug(sprintf('Count of accounts before LAP: %d', $accounts->count()));
|
||||||
|
/** @var LengthAwarePaginator $accounts */
|
||||||
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
|
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
|
||||||
$accounts->setPath(route('accounts.index', [$objectType]));
|
$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'));
|
return view('accounts.index', compact('objectType', 'inactiveCount', 'subTitleIcon', 'subTitle', 'page', 'accounts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user