mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Fix #853
This commit is contained in:
@@ -20,6 +20,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ExecuteRuleOnExistingTransactions
|
||||
@@ -128,18 +129,27 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
|
||||
{
|
||||
// Lookup all journals that match the parameters specified
|
||||
$transactions = $this->collectJournals();
|
||||
$processor = Processor::make($this->rule);
|
||||
|
||||
$processor = Processor::make($this->rule, true);
|
||||
$hits = 0;
|
||||
$misses = 0;
|
||||
$total = 0;
|
||||
// Execute the rules for each transaction
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$processor->handleTransaction($transaction);
|
||||
|
||||
$total++;
|
||||
$result = $processor->handleTransaction($transaction);
|
||||
if($result) {
|
||||
$hits++;
|
||||
}
|
||||
if(!$result) {
|
||||
$misses++;
|
||||
}
|
||||
Log::info(sprintf('Current progress: %d Transactions. Hits: %d, misses: %d', $total, $hits, $misses));
|
||||
// Stop processing this group if the rule specifies 'stop_processing'
|
||||
if ($processor->getRule()->stop_processing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log::info(sprintf('Total transactions: %d. Hits: %d, misses: %d', $total, $hits, $misses));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ final class Processor
|
||||
public $rule;
|
||||
/** @var Collection */
|
||||
public $triggers;
|
||||
|
||||
/** @var int */
|
||||
protected $foundTriggers = 0;
|
||||
|
||||
/**
|
||||
@@ -170,9 +170,14 @@ final class Processor
|
||||
// get all triggers:
|
||||
$triggered = $this->triggered();
|
||||
if ($triggered) {
|
||||
Log::debug('Rule is triggered, go to actions.');
|
||||
if ($this->actions->count() > 0) {
|
||||
Log::debug('Has more than zero actions.');
|
||||
$this->actions();
|
||||
}
|
||||
if ($this->actions->count() === 0) {
|
||||
Log::info('Rule has no actions!');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user