mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Activate caching.
This commit is contained in:
@@ -16,7 +16,6 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -118,7 +117,13 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getCreditCards(Carbon $date)
|
public function getCreditCards(Carbon $date)
|
||||||
{
|
{
|
||||||
return Auth::user()->accounts()
|
$cache = new CacheProperties();
|
||||||
|
$cache->addProperty('user-credit-cards');
|
||||||
|
if ($cache->has()) {
|
||||||
|
return $cache->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$set = Auth::user()->accounts()
|
||||||
->hasMetaValue('accountRole', 'ccAsset')
|
->hasMetaValue('accountRole', 'ccAsset')
|
||||||
->hasMetaValue('ccType', 'monthlyFull')
|
->hasMetaValue('ccType', 'monthlyFull')
|
||||||
->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
||||||
@@ -134,6 +139,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
|
DB::Raw('SUM(`transactions`.`amount`) AS `balance`')
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
$cache->store($set);
|
||||||
|
|
||||||
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -411,7 +411,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('bills-paid-in-range');
|
$cache->addProperty('bills-paid-in-range');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
//return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$bills = $this->getActiveBills();
|
$bills = $this->getActiveBills();
|
||||||
@@ -472,7 +472,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('bills-unpaid-in-range');
|
$cache->addProperty('bills-unpaid-in-range');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
//return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$bills = $this->getActiveBills();
|
$bills = $this->getActiveBills();
|
||||||
@@ -519,7 +519,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('credit-card-bill');
|
$cache->addProperty('credit-card-bill');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
//return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
$accountRepository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
Reference in New Issue
Block a user