mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Some code cleanup.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace FireflyIII\Repositories\Shared;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,21 @@ class ComponentRepository
|
||||
*/
|
||||
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
// we must cache this.
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($object->id);
|
||||
$cache->addProperty(get_class($object));
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($shared);
|
||||
$cache->addProperty('spentInPeriod');
|
||||
|
||||
if($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
if ($shared === true) {
|
||||
// shared is true.
|
||||
// always ignore transfers between accounts!
|
||||
@@ -51,6 +67,8 @@ class ComponentRepository
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
}
|
||||
|
||||
$cache->store($sum);
|
||||
|
||||
return $sum;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user