Some code cleanup.

This commit is contained in:
James Cole
2015-06-05 19:02:23 +02:00
parent 40e49ffc37
commit 681167bc1b
9 changed files with 171 additions and 84 deletions

View File

@@ -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;
}
}