Implemented filter not to return all transactions when testing filters

This commit is contained in:
Robert Horlings 2016-02-17 16:23:43 +01:00
parent 8fdc6c11e1
commit 7ec5cce2c8
3 changed files with 14 additions and 5 deletions

View File

@ -339,7 +339,11 @@ class RuleController extends Controller
*/ */
public function testTriggers() { public function testTriggers() {
// Create a list of triggers // Create a list of triggers
$triggers = $this->getTriggerList(); $triggers = $this->getValidTriggerList();
if(count($triggers) == 0) {
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers') ]);
}
// We start searching for transactions. For performance reasons, there are limits // We start searching for transactions. For performance reasons, there are limits
// to the search: a maximum number of results and a maximum number of transactions // to the search: a maximum number of results and a maximum number of transactions
@ -370,10 +374,11 @@ class RuleController extends Controller
} }
/** /**
* Returns a list of triggers as provided in the URL * Returns a list of triggers as provided in the URL.
* Only returns triggers that will not match any transaction
* @return array * @return array
*/ */
protected function getTriggerList() { protected function getValidTriggerList() {
$triggers = []; $triggers = [];
$order = 1; $order = 1;
$data = [ $data = [
@ -395,9 +400,11 @@ class RuleController extends Controller
$ruleTrigger->trigger_value = $value; $ruleTrigger->trigger_value = $value;
// Store in list // Store in list
if( !$ruleTrigger->matchesAnything() ) {
$triggers[] = $ruleTrigger; $triggers[] = $ruleTrigger;
$order++; $order++;
} }
}
return $triggers; return $triggers;
} }

View File

@ -129,6 +129,7 @@ return [
'test_rule_triggers' => 'See matching transactions', 'test_rule_triggers' => 'See matching transactions',
'warning_transaction_subset' => 'For performance reasons this list is limited to :max_num_transactions and may only show a subset of matching transactions', 'warning_transaction_subset' => 'For performance reasons this list is limited to :max_num_transactions and may only show a subset of matching transactions',
'warning_no_matching_transactions' => 'No matching transactions found. Please note that for performance reasons, only the last :num_transactions transactions have been checked.', 'warning_no_matching_transactions' => 'No matching transactions found. Please note that for performance reasons, only the last :num_transactions transactions have been checked.',
'warning_no_valid_triggers' => 'No valid triggers provided.',
// actions and triggers // actions and triggers
'rule_trigger_user_action' => 'User action is ":trigger_value"', 'rule_trigger_user_action' => 'User action is ":trigger_value"',

View File

@ -128,6 +128,7 @@ return [
'test_rule_triggers' => 'Transacties die voldoen aan triggers', 'test_rule_triggers' => 'Transacties die voldoen aan triggers',
'warning_transaction_subset' => 'In verband met de snelheid, worden in deze lijst maximaal :max_num_transactions transacties weergegeven. Het kan daarom zijn dat transacties ontbreken in deze lijst.', 'warning_transaction_subset' => 'In verband met de snelheid, worden in deze lijst maximaal :max_num_transactions transacties weergegeven. Het kan daarom zijn dat transacties ontbreken in deze lijst.',
'warning_no_matching_transactions' => 'Er zijn geen transacties gevonden die voldoen aan de triggers in de laatste :num_transactions transacties.', 'warning_no_matching_transactions' => 'Er zijn geen transacties gevonden die voldoen aan de triggers in de laatste :num_transactions transacties.',
'warning_no_valid_triggers' => 'Geen geldige triggers opgegeven.',
// actions and triggers // actions and triggers
'rule_trigger_user_action' => 'Gebruikersactie is ":trigger_value"', 'rule_trigger_user_action' => 'Gebruikersactie is ":trigger_value"',