Fix https://github.com/firefly-iii/firefly-iii/issues/8291 AND fix issue with non-strict rule triggers AND fix behaviour of actions

This commit is contained in:
James Cole
2023-12-25 06:03:56 +01:00
parent 2b90c20db8
commit 1bd1a9cba3
5 changed files with 36 additions and 12 deletions

View File

@@ -226,16 +226,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.41.1", "version": "v3.42.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6" "reference": "632ef1be3447a9b890bef06147475facee535d0f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8b6ae8dcbaf23f09680643ab832a4a3a260265f6", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/632ef1be3447a9b890bef06147475facee535d0f",
"reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6", "reference": "632ef1be3447a9b890bef06147475facee535d0f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -266,7 +266,6 @@
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpunit/phpunit": "^9.6", "phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0" "symfony/yaml": "^5.4 || ^6.0 || ^7.0"
}, },
"suggest": { "suggest": {
@@ -305,7 +304,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.1" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.42.0"
}, },
"funding": [ "funding": [
{ {
@@ -313,7 +312,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-12-10T19:59:27+00:00" "time": "2023-12-24T14:38:51+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",

View File

@@ -680,10 +680,11 @@ trait MetaCollection
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list);
$filter = static function (array $object) use ($list): bool { $filter = static function (array $object) use ($list): bool {
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
$expectedTagCount = count($list); $expectedTagCount = count($list);
$foundTagCount = 0; $foundTagCount = 0;
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
$transactionTagCount = count($transaction['tags']); $transactionTagCount = count($transaction['tags']);
app('log')->debug(sprintf('Transaction has %d tag(s)', $transactionTagCount)); app('log')->debug(sprintf('Transaction has %d tag(s)', $transactionTagCount));
@@ -719,6 +720,7 @@ trait MetaCollection
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$list = array_map('strtolower', $list);
$filter = static function (array $object) use ($list): bool { $filter = static function (array $object) use ($list): bool {
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list))); Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {

View File

@@ -325,6 +325,12 @@ class SearchRuleEngine implements RuleEngineInterface
$total = $total->merge($collection); $total = $total->merge($collection);
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count())); app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
++$count; ++$count;
// if trigger says stop processing, do so.
if($ruleTrigger->stop_processing && $collection->count() > 0) {
app('log')->debug('The trigger says to stop processing, so stop processing other triggers.');
break;
}
} }
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count())); app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
app('log')->debug(sprintf('Done running %d trigger(s)', $count)); app('log')->debug(sprintf('Done running %d trigger(s)', $count));
@@ -465,11 +471,14 @@ class SearchRuleEngine implements RuleEngineInterface
} }
// pick up from the action if it actually acted or not: // pick up from the action if it actually acted or not:
if ($ruleAction->stop_processing) { if ($ruleAction->stop_processing && true === $result) {
app('log')->debug(sprintf('Rule action "%s" asks to break, so break!', $ruleAction->action_type)); app('log')->debug(sprintf('Rule action "%s" reports changes AND asks to break, so break!', $ruleAction->action_type));
return true; return true;
} }
if ($ruleAction->stop_processing && false === $result) {
app('log')->debug(sprintf('Rule action "%s" reports NO changes AND asks to break, but we wont break!', $ruleAction->action_type));
}
return false; return false;
} }

View File

@@ -41,14 +41,26 @@ $(function () {
console.log('action count is zero, add action.'); console.log('action count is zero, add action.');
addNewAction(); addNewAction();
} }
makeRuleStrict();
$('.add_rule_trigger').click(addNewTrigger); $('.add_rule_trigger').click(addNewTrigger);
$('.add_rule_action').click(addNewAction); $('.add_rule_action').click(addNewAction);
$('#ffInput_strict').change(makeRuleStrict);
$('.test_rule_triggers').click(testRuleTriggers); $('.test_rule_triggers').click(testRuleTriggers);
$('.remove-trigger').unbind('click').click(removeTrigger); $('.remove-trigger').unbind('click').click(removeTrigger);
$('.remove-action').unbind('click').click(removeAction); $('.remove-action').unbind('click').click(removeAction);
}); });
function makeRuleStrict() {
var value = $('#ffInput_strict').is(':checked');
if(value) {
// is checked, stop processing triggers is not relevant.
$('.trigger-stop-processing').prop('checked', false);
$('.trigger-stop-processing').prop('disabled', true);
return;
}
$('.trigger-stop-processing').prop('disabled', false);
}
/** /**
* This method triggers when a new trigger must be added to the form. * This method triggers when a new trigger must be added to the form.
*/ */
@@ -181,6 +193,7 @@ function onAddNewAction() {
console.log('Trigger updateActionInput() for select ' + select); console.log('Trigger updateActionInput() for select ' + select);
updateActionInput(select); updateActionInput(select);
}); });
makeRuleStrict();
} }
/** /**
@@ -207,6 +220,7 @@ function onAddNewTrigger() {
console.log('Trigger updateTriggerInput() for select ' + select); console.log('Trigger updateTriggerInput() for select ' + select);
updateTriggerInput(select); updateTriggerInput(select);
}); });
makeRuleStrict();
} }
/** /**

View File

@@ -34,7 +34,7 @@
<td style="width:20%;"> <td style="width:20%;">
<div class="checkbox"> <div class="checkbox">
<label> <label>
<input type="checkbox" name="triggers[{{ count }}][stop_processing]" value="1" <input type="checkbox" class="trigger-stop-processing" name="triggers[{{ count }}][stop_processing]" value="1"
{% if oldChecked %}checked{% endif %} {% if oldChecked %}checked{% endif %}
/> />
</label> </label>