From 71ef5abea51af0c466cc2a29c3de90837698cd65 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 24 Aug 2020 18:31:10 +0200 Subject: [PATCH] Remove references to unused code. --- app/Api/V1/Controllers/RuleController.php | 50 ++++++------ .../V1/Controllers/RuleGroupController.php | 78 +++++++++---------- app/Api/V1/Requests/RuleGroupTestRequest.php | 72 +++-------------- app/Api/V1/Requests/RuleTestRequest.php | 72 ++++------------- app/Api/V1/Requests/RuleTriggerRequest.php | 8 +- app/Http/Controllers/Bill/ShowController.php | 23 +++--- .../Controllers/Rule/SelectController.php | 45 +++-------- 7 files changed, 115 insertions(+), 233 deletions(-) diff --git a/app/Api/V1/Controllers/RuleController.php b/app/Api/V1/Controllers/RuleController.php index 1ffa018fd0..07bdae9d44 100644 --- a/app/Api/V1/Controllers/RuleController.php +++ b/app/Api/V1/Controllers/RuleController.php @@ -28,13 +28,10 @@ use FireflyIII\Api\V1\Requests\RuleTestRequest; use FireflyIII\Api\V1\Requests\RuleTriggerRequest; use FireflyIII\Api\V1\Requests\RuleUpdateRequest; use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\Rule; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Rule\RuleRepositoryInterface; -use FireflyIII\TransactionRules\Engine\RuleEngine; use FireflyIII\TransactionRules\Engine\RuleEngineInterface; -use FireflyIII\TransactionRules\TransactionMatcher; use FireflyIII\Transformers\RuleTransformer; use FireflyIII\Transformers\TransactionGroupTransformer; use FireflyIII\User; @@ -44,7 +41,6 @@ use Illuminate\Support\Collection; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Item; -use Log; /** * Class RuleController @@ -222,24 +218,32 @@ class RuleController extends Controller */ public function testRule(RuleTestRequest $request, Rule $rule): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $parameters = $request->getTestParameters(); - /** @var Rule $rule */ - Log::debug(sprintf('Now testing rule #%d, "%s"', $rule->id, $rule->title)); - /** @var TransactionMatcher $matcher */ - $matcher = app(TransactionMatcher::class); - // set all parameters: - $matcher->setRule($rule); - $matcher->setStartDate($parameters['start_date']); - $matcher->setEndDate($parameters['end_date']); - $matcher->setSearchLimit($parameters['search_limit']); - $matcher->setTriggeredLimit($parameters['trigger_limit']); - $matcher->setAccounts($parameters['accounts']); - $matchingTransactions = $matcher->findTransactionsByRule(); - $count = count($matchingTransactions); - $transactions = array_slice($matchingTransactions, ($parameters['page'] - 1) * $pageSize, $pageSize); - $paginator = new LengthAwarePaginator($transactions, $count, $pageSize, $this->parameters->get('page')); + /** @var RuleEngineInterface $ruleEngine */ + $ruleEngine = app(RuleEngineInterface::class); + $ruleEngine->setRules(new Collection([$rule])); + + + // overrule the rule(s) if necessary. + if (array_key_exists('start', $parameters) && null !== $parameters['start']) { + // add a range: + $ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]); + } + + if (array_key_exists('end', $parameters) && null !== $parameters['end']) { + // add a range: + $ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]); + } + if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) { + $ruleEngine->addOperator(['type' => 'account_id', 'value' => $parameters['accounts']]); + } + + // file the rule(s) + $transactions = $ruleEngine->find(); + $count = $transactions->count(); + + $paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page')); $paginator->setPath(route('api.v1.rules.test', [$rule->id]) . $this->buildParams()); // resulting list is presented as JSON thing. @@ -248,7 +252,7 @@ class RuleController extends Controller $transformer = app(TransactionGroupTransformer::class); $transformer->setParameters($this->parameters); - $resource = new FractalCollection($matchingTransactions, $transformer, 'transactions'); + $resource = new FractalCollection($transactions, $transformer, 'transactions'); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); @@ -272,12 +276,12 @@ class RuleController extends Controller $ruleEngine->setRules(new Collection([$rule])); // overrule the rule(s) if necessary. - if (array_key_exists('start', $parameters) && null !== $parameters['start'] ) { + if (array_key_exists('start', $parameters) && null !== $parameters['start']) { // add a range: $ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]); } - if (array_key_exists('end', $parameters) && null !== $parameters['end']) { + if (array_key_exists('end', $parameters) && null !== $parameters['end']) { // add a range: $ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]); } diff --git a/app/Api/V1/Controllers/RuleGroupController.php b/app/Api/V1/Controllers/RuleGroupController.php index e1fc1f309c..4716bca2fa 100644 --- a/app/Api/V1/Controllers/RuleGroupController.php +++ b/app/Api/V1/Controllers/RuleGroupController.php @@ -28,14 +28,10 @@ use FireflyIII\Api\V1\Requests\RuleGroupRequest; use FireflyIII\Api\V1\Requests\RuleGroupTestRequest; use FireflyIII\Api\V1\Requests\RuleGroupTriggerRequest; use FireflyIII\Exceptions\FireflyException; -use FireflyIII\Helpers\Collector\GroupCollectorInterface; -use FireflyIII\Models\Rule; use FireflyIII\Models\RuleGroup; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; -use FireflyIII\TransactionRules\Engine\RuleEngine; use FireflyIII\TransactionRules\Engine\RuleEngineInterface; -use FireflyIII\TransactionRules\TransactionMatcher; use FireflyIII\Transformers\RuleGroupTransformer; use FireflyIII\Transformers\RuleTransformer; use FireflyIII\Transformers\TransactionGroupTransformer; @@ -46,7 +42,6 @@ use Illuminate\Support\Collection; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Item; -use Log; /** * Class RuleGroupController @@ -249,54 +244,51 @@ class RuleGroupController extends Controller * @param RuleGroupTestRequest $request * @param RuleGroup $group * + * @return JsonResponse * @throws FireflyException * - * @return JsonResponse */ public function testGroup(RuleGroupTestRequest $request, RuleGroup $group): JsonResponse { - $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; - Log::debug('Now in testGroup()'); /** @var Collection $rules */ $rules = $this->ruleGroupRepository->getActiveRules($group); if (0 === $rules->count()) { throw new FireflyException('200023: No rules in this rule group.'); } - $parameters = $request->getTestParameters(); - $matchingTransactions = []; + $parameters = $request->getTestParameters(); - Log::debug(sprintf('Going to test %d rules', $rules->count())); - /** @var Rule $rule */ - foreach ($rules as $rule) { - Log::debug(sprintf('Now testing rule #%d, "%s"', $rule->id, $rule->title)); - /** @var TransactionMatcher $matcher */ - $matcher = app(TransactionMatcher::class); - // set all parameters: - $matcher->setRule($rule); - $matcher->setStartDate($parameters['start_date']); - $matcher->setEndDate($parameters['end_date']); - $matcher->setSearchLimit($parameters['search_limit']); - $matcher->setTriggeredLimit($parameters['trigger_limit']); - $matcher->setAccounts($parameters['accounts']); + /** @var RuleEngineInterface $ruleEngine */ + $ruleEngine = app(RuleEngineInterface::class); + $ruleEngine->setRules($rules); - $result = $matcher->findTransactionsByRule(); - /** @noinspection AdditionOperationOnArraysInspection */ - $matchingTransactions = $result + $matchingTransactions; + // overrule the rule(s) if necessary. + if (array_key_exists('start', $parameters) && null !== $parameters['start']) { + // add a range: + $ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]); } - // make paginator out of results. - $count = count($matchingTransactions); - $transactions = array_slice($matchingTransactions, ($parameters['page'] - 1) * $pageSize, $pageSize); + if (array_key_exists('end', $parameters) && null !== $parameters['end']) { + // add a range: + $ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]); + } + if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) { + $ruleEngine->addOperator(['type' => 'account_id', 'value' => $parameters['accounts']]); + } - // make paginator: - $paginator = new LengthAwarePaginator($transactions, $count, $pageSize, $parameters['page']); + // file the rule(s) + $transactions = $ruleEngine->find(); + $count = $transactions->count(); + + $paginator = new LengthAwarePaginator($transactions, $count, 31337, $this->parameters->get('page')); $paginator->setPath(route('api.v1.rule_groups.test', [$group->id]) . $this->buildParams()); - $manager = $this->getManager(); + // resulting list is presented as JSON thing. + $manager = $this->getManager(); + /** @var TransactionGroupTransformer $transformer */ $transformer = app(TransactionGroupTransformer::class); $transformer->setParameters($this->parameters); - $resource = new FractalCollection($matchingTransactions, $transformer, 'transactions'); + $resource = new FractalCollection($transactions, $transformer, 'transactions'); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); @@ -308,27 +300,31 @@ class RuleGroupController extends Controller * @param RuleGroupTriggerRequest $request * @param RuleGroup $group * - * @throws Exception * @return JsonResponse + * @throws Exception */ public function triggerGroup(RuleGroupTriggerRequest $request, RuleGroup $group): JsonResponse { + /** @var Collection $rules */ + $rules = $this->ruleGroupRepository->getActiveRules($group); + if (0 === $rules->count()) { + throw new FireflyException('200023: No rules in this rule group.'); + } + + // Get parameters specified by the user $parameters = $request->getTriggerParameters(); - /** @var Collection $collection */ - $collection = $this->ruleGroupRepository->getActiveRules($group); - - // start looping. + /** @var RuleEngineInterface $ruleEngine */ $ruleEngine = app(RuleEngineInterface::class); - $ruleEngine->setRules($collection); + $ruleEngine->setRules($rules); // overrule the rule(s) if necessary. - if (array_key_exists('start', $parameters) && null !== $parameters['start'] ) { + if (array_key_exists('start', $parameters) && null !== $parameters['start']) { // add a range: $ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]); } - if (array_key_exists('end', $parameters) && null !== $parameters['end']) { + if (array_key_exists('end', $parameters) && null !== $parameters['end']) { // add a range: $ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]); } diff --git a/app/Api/V1/Requests/RuleGroupTestRequest.php b/app/Api/V1/Requests/RuleGroupTestRequest.php index 2d922f140a..bc9f0edf94 100644 --- a/app/Api/V1/Requests/RuleGroupTestRequest.php +++ b/app/Api/V1/Requests/RuleGroupTestRequest.php @@ -40,6 +40,7 @@ use Log; class RuleGroupTestRequest extends FormRequest { use ConvertsDataTypes; + /** * Authorize logged in users. * @@ -57,12 +58,9 @@ class RuleGroupTestRequest extends FormRequest public function getTestParameters(): array { return [ - 'page' => $this->getPage(), - 'start_date' => $this->getDate('start_date'), - 'end_date' => $this->getDate('end_date'), - 'search_limit' => $this->getSearchLimit(), - 'trigger_limit' => $this->getTriggerLimit(), - 'accounts' => $this->getAccounts(), + 'start' => $this->getDate('start'), + 'end' => $this->getDate('end'), + 'accounts' => $this->getAccounts(), ]; } @@ -71,31 +69,20 @@ class RuleGroupTestRequest extends FormRequest */ public function rules(): array { - return []; + return [ + 'start' => 'date', + 'end' => 'date|after:start', + 'accounts' => '', + 'accounts.*' => 'exists:accounts,id|belongsToUser:accounts', + ]; } /** * @return Collection */ - private function getAccounts(): Collection + private function getAccounts(): string { - $accountList = '' === (string) $this->query('accounts') ? [] : explode(',', $this->query('accounts')); - $accounts = new Collection; - - /** @var AccountRepositoryInterface $accountRepository */ - $accountRepository = app(AccountRepositoryInterface::class); - - foreach ($accountList as $accountId) { - Log::debug(sprintf('Searching for asset account with id "%s"', $accountId)); - $account = $accountRepository->findNull((int) $accountId); - if ($this->validAccount($account)) { - /** @noinspection NullPointerExceptionInspection */ - Log::debug(sprintf('Found account #%d ("%s") and its an asset account', $account->id, $account->name)); - $accounts->push($account); - } - } - - return $accounts; + return (string) $this->query('accounts'); } /** @@ -111,39 +98,4 @@ class RuleGroupTestRequest extends FormRequest return $result; } - /** - * @return int - */ - private function getPage(): int - { - return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page'); - - } - - /** - * @return int - */ - private function getSearchLimit(): int - { - return 0 === (int) $this->query('search_limit') ? (int) config('firefly.test-triggers.limit') : (int) $this->query('search_limit'); - } - - /** - * @return int - */ - private function getTriggerLimit(): int - { - return 0 === (int) $this->query('triggered_limit') ? (int) config('firefly.test-triggers.range') : (int) $this->query('triggered_limit'); - } - - /** - * @param Account|null $account - * - * @return bool - */ - private function validAccount(?Account $account): bool - { - return null !== $account && AccountType::ASSET === $account->accountType->type; - } - } diff --git a/app/Api/V1/Requests/RuleTestRequest.php b/app/Api/V1/Requests/RuleTestRequest.php index f693ac5779..c823b35585 100644 --- a/app/Api/V1/Requests/RuleTestRequest.php +++ b/app/Api/V1/Requests/RuleTestRequest.php @@ -26,13 +26,8 @@ namespace FireflyIII\Api\V1\Requests; use Carbon\Carbon; -use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; -use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Collection; -use Log; /** * Class RuleTestRequest @@ -40,6 +35,7 @@ use Log; class RuleTestRequest extends FormRequest { use ConvertsDataTypes; + /** * Authorize logged in users. * @@ -57,12 +53,11 @@ class RuleTestRequest extends FormRequest public function getTestParameters(): array { return [ - 'page' => $this->getPage(), - 'start_date' => $this->getDate('start_date'), - 'end_date' => $this->getDate('end_date'), - 'search_limit' => $this->getSearchLimit(), - 'trigger_limit' => $this->getTriggerLimit(), - 'accounts' => $this->getAccounts(), + 'page' => $this->getPage(), + 'start' => $this->getDate('start'), + 'end' => $this->getDate('end'), + 'accounts' => $this->getAccounts(), + ]; } @@ -71,31 +66,20 @@ class RuleTestRequest extends FormRequest */ public function rules(): array { - return []; + return [ + 'start' => 'date', + 'end' => 'date|after:start', + 'accounts' => '', + 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts', + ]; } /** - * @return Collection + * @return string */ - private function getAccounts(): Collection + private function getAccounts(): string { - $accountList = '' === (string) $this->query('accounts') ? [] : explode(',', $this->query('accounts')); - $accounts = new Collection; - - /** @var AccountRepositoryInterface $accountRepository */ - $accountRepository = app(AccountRepositoryInterface::class); - - foreach ($accountList as $accountId) { - Log::debug(sprintf('Searching for asset account with id "%s"', $accountId)); - $account = $accountRepository->findNull((int) $accountId); - if ($this->validAccount($account)) { - /** @noinspection NullPointerExceptionInspection */ - Log::debug(sprintf('Found account #%d ("%s") and its an asset account', $account->id, $account->name)); - $accounts->push($account); - } - } - - return $accounts; + return (string) $this->query('accounts'); } /** @@ -120,30 +104,4 @@ class RuleTestRequest extends FormRequest } - /** - * @return int - */ - private function getSearchLimit(): int - { - return 0 === (int) $this->query('search_limit') ? (int) config('firefly.test-triggers.limit') : (int) $this->query('search_limit'); - } - - /** - * @return int - */ - private function getTriggerLimit(): int - { - return 0 === (int) $this->query('triggered_limit') ? (int) config('firefly.test-triggers.range') : (int) $this->query('triggered_limit'); - } - - /** - * @param Account|null $account - * - * @return bool - */ - private function validAccount(?Account $account): bool - { - return null !== $account && AccountType::ASSET === $account->accountType->type; - } - } diff --git a/app/Api/V1/Requests/RuleTriggerRequest.php b/app/Api/V1/Requests/RuleTriggerRequest.php index 218e2c2534..407d9de810 100644 --- a/app/Api/V1/Requests/RuleTriggerRequest.php +++ b/app/Api/V1/Requests/RuleTriggerRequest.php @@ -26,8 +26,6 @@ namespace FireflyIII\Api\V1\Requests; use Carbon\Carbon; -use FireflyIII\Models\Account; -use FireflyIII\Models\AccountType; use FireflyIII\Support\Request\ConvertsDataTypes; use Illuminate\Foundation\Http\FormRequest; @@ -67,8 +65,10 @@ class RuleTriggerRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date', - 'end' => 'date|after:start', + 'start' => 'date', + 'end' => 'date|after:start', + 'accounts' => '', + 'accounts.*' => 'exists:accounts,id|belongsToUser:accounts', ]; } diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php index 8cc8b0b6dd..8cee88df51 100644 --- a/app/Http/Controllers/Bill/ShowController.php +++ b/app/Http/Controllers/Bill/ShowController.php @@ -31,7 +31,7 @@ use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Attachment; use FireflyIII\Models\Bill; use FireflyIII\Repositories\Bill\BillRepositoryInterface; -use FireflyIII\TransactionRules\TransactionMatcher; +use FireflyIII\TransactionRules\Engine\RuleEngineInterface; use FireflyIII\Transformers\AttachmentTransformer; use FireflyIII\Transformers\BillTransformer; use Illuminate\Contracts\View\Factory; @@ -73,14 +73,15 @@ class ShowController extends Controller } ); } + /** * Rescan bills for transactions. * * @param Request $request * @param Bill $bill * - * @throws FireflyException * @return RedirectResponse|Redirector + * @throws FireflyException */ public function rescan(Request $request, Bill $bill) { @@ -104,18 +105,13 @@ class ShowController extends Controller // unlink all journals: $this->repository->unlinkAll($bill); - foreach ($set as $rule) { - // simply fire off all rules? - /** @var TransactionMatcher $matcher */ - $matcher = app(TransactionMatcher::class); - $matcher->setSearchLimit(100000); // large upper limit - $matcher->setTriggeredLimit(100000); // large upper limit - $matcher->setRule($rule); - $matchingTransactions = $matcher->findTransactionsByRule(); - $total += count($matchingTransactions); - $this->repository->linkCollectionToBill($bill, $matchingTransactions); - } + // fire the rules: + /** @var RuleEngineInterface $ruleEngine */ + $ruleEngine = app(RuleEngineInterface::class); + $ruleEngine->setRules($set); + // file the rule(s) + $ruleEngine->fire(); $request->session()->flash('success', (string) trans_choice('firefly.rescanned_bill', $total)); app('preferences')->mark(); @@ -124,7 +120,6 @@ class ShowController extends Controller } - /** * Show a bill. * diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php index 7d8f41f938..5318db4df1 100644 --- a/app/Http/Controllers/Rule/SelectController.php +++ b/app/Http/Controllers/Rule/SelectController.php @@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Rule; use Carbon\Carbon; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\SelectTransactionsRequest; use FireflyIII\Http\Requests\TestRuleFormRequest; @@ -131,10 +130,6 @@ class SelectController extends Controller * This method allows the user to test a certain set of rule triggers. The rule triggers are passed along * using the URL parameters (GET), and are usually put there using a Javascript thing. * - * This method will parse and validate those rules and create a "TransactionMatcher" which will attempt - * to find transaction journals matching the users input. A maximum range of transactions to try (range) and - * a maximum number of transactions to return (limit) are set as well. - * * @param TestRuleFormRequest $request * * @return JsonResponse @@ -170,7 +165,7 @@ class SelectController extends Controller // set rules: $newRuleEngine->setRules(new Collection([$rule])); $collection = $newRuleEngine->find(); - $collection = $collection->slice(0,20); + $collection = $collection->slice(0, 20); // Warn the user if only a subset of transactions is returned $warning = ''; @@ -198,10 +193,6 @@ class SelectController extends Controller * This method allows the user to test a certain set of rule triggers. The rule triggers are grabbed from * the rule itself. * - * This method will parse and validate those rules and create a "TransactionMatcher" which will attempt - * to find transaction journals matching the users input. A maximum range of transactions to try (range) and - * a maximum number of transactions to return (limit) are set as well. - * * @param Rule $rule * * @return JsonResponse @@ -215,37 +206,23 @@ class SelectController extends Controller return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore } - $limit = (int) config('firefly.test-triggers.limit'); - $range = (int) config('firefly.test-triggers.range'); - $matchingTransactions = new Collection; - /** @var TransactionMatcher $matcher */ - $matcher = app(TransactionMatcher::class); - $matcher->setTriggeredLimit($limit); - $matcher->setSearchLimit($range); - $matcher->setRule($rule); - try { - $matchingTransactions = $matcher->findTransactionsByRule(); - // @codeCoverageIgnoreStart - } catch (FireflyException $exception) { - Log::error(sprintf('Could not grab transactions in testTriggersByRule(): %s', $exception->getMessage())); - Log::error($exception->getTraceAsString()); - } - // @codeCoverageIgnoreEnd + // create new rule engine: + $newRuleEngine = app(RuleEngineInterface::class); - // Warn the user if only a subset of transactions is returned - $warning = ''; - if (count($matchingTransactions) === $limit) { - $warning = (string) trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]); // @codeCoverageIgnore - } - if (0 === count($matchingTransactions)) { - $warning = (string) trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]); // @codeCoverageIgnore + // set rules: + $newRuleEngine->setRules(new Collection([$rule])); + $collection = $newRuleEngine->find(); + $collection = $collection->slice(0, 20); + + if (0 === count($collection)) { + $warning = (string) trans('firefly.warning_no_matching_transactions'); // @codeCoverageIgnore } // Return json response $view = 'ERROR, see logs.'; try { - $view = view('list.journals-array-tiny', ['journals' => $matchingTransactions])->render(); + $view = view('list.journals-array-tiny', ['groups' => $collection])->render(); // @codeCoverageIgnoreStart } catch (Throwable $exception) { Log::error(sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()));