Skip to content

Firefly III: a personal finances manager

Some more last-minute fixes.

James Cole2f824ba1a8f0
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index 427da305d9..b2eb90dc1a 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -61,6 +61,7 @@ use Steam;
*/
class JournalCollector implements JournalCollectorInterface
{
+
/** @var array */
private $accountIds = [];
/** @var int */
@@ -107,7 +108,8 @@ class JournalCollector implements JournalCollectorInterface
];
/** @var array */
private $filters = [InternalTransferFilter::class];
-
+ /** @var bool */
+ private $ignoreCache = false;
/** @var bool */
private $joinedBudget = false;
/** @var bool */
@@ -258,12 +260,15 @@ class JournalCollector implements JournalCollectorInterface
foreach ($this->filters as $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));
return $cache->get(); // @codeCoverageIgnore
- }
+ }
+ if (true === $this->ignoreCache) {
+ Log::debug('Ignore cache in journal collector.');
+ }
/** @var Collection $set */
$set = $this->query->get(array_values($this->fields));
@@ -316,6 +321,16 @@ class JournalCollector implements JournalCollectorInterface
return $journals;
}
+ /**
+ * @return JournalCollectorInterface
+ */
+ public function ignoreCache(): JournalCollectorInterface
+ {
+ $this->ignoreCache = true;
+
+ return $this;
+ }
+
/**
* @param string $filter
*
@@ -786,7 +801,7 @@ class JournalCollector implements JournalCollectorInterface
/**
*
*/
- private function joinBudgetTables()
+ private function joinBudgetTables(): void
{
if (!$this->joinedBudget) {
// join some extra tables:
@@ -811,7 +826,7 @@ class JournalCollector implements JournalCollectorInterface
/**
*
*/
- private function joinCategoryTables()
+ private function joinCategoryTables(): void
{
if (!$this->joinedCategory) {
// join some extra tables:
@@ -841,7 +856,7 @@ class JournalCollector implements JournalCollectorInterface
/**
*
*/
- private function joinOpposingTables()
+ private function joinOpposingTables(): void
{
if (!$this->joinedOpposing) {
Log::debug('joinedOpposing is false');
@@ -873,7 +888,7 @@ class JournalCollector implements JournalCollectorInterface
/**
*
*/
- private function joinTagTables()
+ private function joinTagTables(): void
{
if (!$this->joinedTag) {
// join some extra tables:
diff --git a/app/Helpers/Collector/JournalCollectorInterface.php b/app/Helpers/Collector/JournalCollectorInterface.php
index 1b439a748b..b710326175 100644
--- a/app/Helpers/Collector/JournalCollectorInterface.php
+++ b/app/Helpers/Collector/JournalCollectorInterface.php
@@ -78,6 +78,11 @@ interface JournalCollectorInterface
*/
public function getPaginatedJournals(): LengthAwarePaginator;
+ /**
+ * @return JournalCollectorInterface
+ */
+ public function ignoreCache(): JournalCollectorInterface;
+
/**
* @param string $filter
*
diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php
index 70d050c354..01315fbe9f 100644
--- a/app/Import/Storage/ImportArrayStorage.php
+++ b/app/Import/Storage/ImportArrayStorage.php
@@ -154,7 +154,9 @@ class ImportArrayStorage
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) {
Log::debug(sprintf('Count is %d', $count));
$this->checkForTransfers = true;
@@ -206,16 +208,19 @@ class ImportArrayStorage
*/
private function getTransfers(): void
{
+ Log::debug('Now in getTransfers()');
app('preferences')->mark();
+
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setUser($this->importJob->user);
$collector->setAllAssetAccounts()
+ ->ignoreCache()
->setTypes([TransactionType::TRANSFER])
->withOpposingAccount();
$collector->removeFilter(InternalTransferFilter::class);
$this->transfers = $collector->getJournals();
-
+ Log::debug(sprintf('Count of getTransfers() is %d', $this->transfers->count()));
}
/**