Skip to content

Firefly III: a personal finances manager

Make note of some query heavy pages.

James Cole386c067e937b
diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php
index 201bf61bd6..e9cdb74072 100644
--- a/app/Http/Controllers/Account/IndexController.php
+++ b/app/Http/Controllers/Account/IndexController.php
@@ -152,13 +152,15 @@ class IndexController extends Controller
}
$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();
-
unset($collection);
/** @var Carbon $start */
$start = clone session('start', Carbon::now()->startOfMonth());
@@ -173,6 +175,7 @@ class IndexController extends Controller
$accounts->each(
function (Account $account) use ($activities, $startBalances, $endBalances) {
+ // TODO lots of queries executed in this block.
$account->lastActivityDate = $this->isInArray($activities, $account->id);
$account->startBalance = $this->isInArray($startBalances, $account->id);
$account->endBalance = $this->isInArray($endBalances, $account->id);
@@ -183,7 +186,6 @@ class IndexController extends Controller
$account->location = $this->repository->getLocation($account);
}
);
-
// make paginator:
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
$accounts->setPath(route('accounts.index', [$objectType]));
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php
index 42b6054f2b..233d991385 100644
--- a/app/Support/Twig/AmountFormat.php
+++ b/app/Support/Twig/AmountFormat.php
@@ -76,7 +76,9 @@ class AmountFormat extends AbstractExtension
/**
* Will format the amount by the currency related to the given account.
*
- * @return TwigFunction;
+ * @return TwigFunction
+ * @deprecated
+ * TODO remove me because it executes a query in a view.
*/
protected function formatAmountByAccount(): TwigFunction
{
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index db23187d9b..b5aec234fc 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -225,6 +225,8 @@ class General extends AbstractExtension
/**
* @return TwigFunction
+ * @deprecated because it uses a query in a view
+ * TODO remove me.
*/
protected function getMetaField(): TwigFunction
{