Some more last-minute fixes.

This commit is contained in:
James Cole
2018-06-02 19:23:46 +02:00
parent a6b09acd5e
commit 2f824ba1a8
3 changed files with 34 additions and 9 deletions

View File

@@ -61,6 +61,7 @@ use Steam;
*/ */
class JournalCollector implements JournalCollectorInterface class JournalCollector implements JournalCollectorInterface
{ {
/** @var array */ /** @var array */
private $accountIds = []; private $accountIds = [];
/** @var int */ /** @var int */
@@ -107,7 +108,8 @@ class JournalCollector implements JournalCollectorInterface
]; ];
/** @var array */ /** @var array */
private $filters = [InternalTransferFilter::class]; private $filters = [InternalTransferFilter::class];
/** @var bool */
private $ignoreCache = false;
/** @var bool */ /** @var bool */
private $joinedBudget = false; private $joinedBudget = false;
/** @var bool */ /** @var bool */
@@ -258,12 +260,15 @@ class JournalCollector implements JournalCollectorInterface
foreach ($this->filters as $filter) { foreach ($this->filters as $filter) {
$cache->addProperty((string)$filter); $cache->addProperty((string)$filter);
} }
if ($cache->has()) { if (false === $this->ignoreCache && $cache->has()) {
Log::debug(sprintf('Return cache of query with ID "%s".', $key)); Log::debug(sprintf('Return cache of query with ID "%s".', $key));
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
}
}
if (true === $this->ignoreCache) {
Log::debug('Ignore cache in journal collector.');
}
/** @var Collection $set */ /** @var Collection $set */
$set = $this->query->get(array_values($this->fields)); $set = $this->query->get(array_values($this->fields));
@@ -316,6 +321,16 @@ class JournalCollector implements JournalCollectorInterface
return $journals; return $journals;
} }
/**
* @return JournalCollectorInterface
*/
public function ignoreCache(): JournalCollectorInterface
{
$this->ignoreCache = true;
return $this;
}
/** /**
* @param string $filter * @param string $filter
* *
@@ -786,7 +801,7 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
*/ */
private function joinBudgetTables() private function joinBudgetTables(): void
{ {
if (!$this->joinedBudget) { if (!$this->joinedBudget) {
// join some extra tables: // join some extra tables:
@@ -811,7 +826,7 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
*/ */
private function joinCategoryTables() private function joinCategoryTables(): void
{ {
if (!$this->joinedCategory) { if (!$this->joinedCategory) {
// join some extra tables: // join some extra tables:
@@ -841,7 +856,7 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
*/ */
private function joinOpposingTables() private function joinOpposingTables(): void
{ {
if (!$this->joinedOpposing) { if (!$this->joinedOpposing) {
Log::debug('joinedOpposing is false'); Log::debug('joinedOpposing is false');
@@ -873,7 +888,7 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
*/ */
private function joinTagTables() private function joinTagTables(): void
{ {
if (!$this->joinedTag) { if (!$this->joinedTag) {
// join some extra tables: // join some extra tables:

View File

@@ -78,6 +78,11 @@ interface JournalCollectorInterface
*/ */
public function getPaginatedJournals(): LengthAwarePaginator; public function getPaginatedJournals(): LengthAwarePaginator;
/**
* @return JournalCollectorInterface
*/
public function ignoreCache(): JournalCollectorInterface;
/** /**
* @param string $filter * @param string $filter
* *

View File

@@ -154,7 +154,9 @@ class ImportArrayStorage
Log::debug(sprintf('Row #%d is a transfer, increase count to %d', ($index + 1), $count)); Log::debug(sprintf('Row #%d is a transfer, increase count to %d', ($index + 1), $count));
} }
} }
Log::debug('Count is zero.'); if (0 === $count) {
Log::debug('Count is zero.');
}
if ($count > 0) { if ($count > 0) {
Log::debug(sprintf('Count is %d', $count)); Log::debug(sprintf('Count is %d', $count));
$this->checkForTransfers = true; $this->checkForTransfers = true;
@@ -206,16 +208,19 @@ class ImportArrayStorage
*/ */
private function getTransfers(): void private function getTransfers(): void
{ {
Log::debug('Now in getTransfers()');
app('preferences')->mark(); app('preferences')->mark();
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setUser($this->importJob->user); $collector->setUser($this->importJob->user);
$collector->setAllAssetAccounts() $collector->setAllAssetAccounts()
->ignoreCache()
->setTypes([TransactionType::TRANSFER]) ->setTypes([TransactionType::TRANSFER])
->withOpposingAccount(); ->withOpposingAccount();
$collector->removeFilter(InternalTransferFilter::class); $collector->removeFilter(InternalTransferFilter::class);
$this->transfers = $collector->getJournals(); $this->transfers = $collector->getJournals();
Log::debug(sprintf('Count of getTransfers() is %d', $this->transfers->count()));
} }
/** /**