mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 09:52:20 +00:00
Fix #3673
This commit is contained in:
@@ -40,30 +40,19 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class Search implements SearchInterface
|
class Search implements SearchInterface
|
||||||
{
|
{
|
||||||
/** @var AccountRepositoryInterface */
|
private AccountRepositoryInterface $accountRepository;
|
||||||
private $accountRepository;
|
private BillRepositoryInterface $billRepository;
|
||||||
/** @var BillRepositoryInterface */
|
private BudgetRepositoryInterface $budgetRepository;
|
||||||
private $billRepository;
|
private CategoryRepositoryInterface $categoryRepository;
|
||||||
/** @var BudgetRepositoryInterface */
|
private Collection $modifiers;
|
||||||
private $budgetRepository;
|
private string $originalQuery = '';
|
||||||
/** @var CategoryRepositoryInterface */
|
private float $startTime;
|
||||||
private $categoryRepository;
|
private int $limit;
|
||||||
/** @var Collection */
|
private TagRepositoryInterface $tagRepository;
|
||||||
private $modifiers;
|
private User $user;
|
||||||
/** @var string */
|
private array $validModifiers;
|
||||||
private $originalQuery = '';
|
private array $words = [];
|
||||||
/** @var float */
|
private int $page;
|
||||||
private $startTime;
|
|
||||||
/** @var TagRepositoryInterface */
|
|
||||||
private $tagRepository;
|
|
||||||
/** @var User */
|
|
||||||
private $user;
|
|
||||||
/** @var array */
|
|
||||||
private $validModifiers;
|
|
||||||
/** @var array */
|
|
||||||
private $words = [];
|
|
||||||
/** @var int */
|
|
||||||
private $page;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search constructor.
|
* Search constructor.
|
||||||
@@ -72,7 +61,7 @@ class Search implements SearchInterface
|
|||||||
{
|
{
|
||||||
$this->page = 1;
|
$this->page = 1;
|
||||||
$this->modifiers = new Collection;
|
$this->modifiers = new Collection;
|
||||||
$this->validModifiers = (array)config('firefly.search_modifiers');
|
$this->validModifiers = (array) config('firefly.search_modifiers');
|
||||||
$this->startTime = microtime(true);
|
$this->startTime = microtime(true);
|
||||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
||||||
@@ -154,7 +143,9 @@ class Search implements SearchInterface
|
|||||||
public function searchTransactions(): LengthAwarePaginator
|
public function searchTransactions(): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
Log::debug('Start of searchTransactions()');
|
Log::debug('Start of searchTransactions()');
|
||||||
$pageSize = (int) config('firefly.search_result_limit');
|
|
||||||
|
// get limit from preferences.
|
||||||
|
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -245,19 +236,19 @@ class Search implements SearchInterface
|
|||||||
break;
|
break;
|
||||||
case 'amount_is':
|
case 'amount_is':
|
||||||
case 'amount':
|
case 'amount':
|
||||||
$amount = app('steam')->positive((string)$modifier['value']);
|
$amount = app('steam')->positive((string) $modifier['value']);
|
||||||
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
||||||
$collector->amountIs($amount);
|
$collector->amountIs($amount);
|
||||||
break;
|
break;
|
||||||
case 'amount_max':
|
case 'amount_max':
|
||||||
case 'amount_less':
|
case 'amount_less':
|
||||||
$amount = app('steam')->positive((string)$modifier['value']);
|
$amount = app('steam')->positive((string) $modifier['value']);
|
||||||
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
||||||
$collector->amountLess($amount);
|
$collector->amountLess($amount);
|
||||||
break;
|
break;
|
||||||
case 'amount_min':
|
case 'amount_min':
|
||||||
case 'amount_more':
|
case 'amount_more':
|
||||||
$amount = app('steam')->positive((string)$modifier['value']);
|
$amount = app('steam')->positive((string) $modifier['value']);
|
||||||
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $amount));
|
||||||
$collector->amountMore($amount);
|
$collector->amountMore($amount);
|
||||||
break;
|
break;
|
||||||
@@ -312,9 +303,9 @@ class Search implements SearchInterface
|
|||||||
private function extractModifier(string $string): void
|
private function extractModifier(string $string): void
|
||||||
{
|
{
|
||||||
$parts = explode(':', $string);
|
$parts = explode(':', $string);
|
||||||
if (2 === count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
|
if (2 === count($parts) && '' !== trim((string) $parts[1]) && '' !== trim((string) $parts[0])) {
|
||||||
$type = strtolower(trim((string)$parts[0]));
|
$type = strtolower(trim((string) $parts[0]));
|
||||||
$value = trim((string)$parts[1]);
|
$value = trim((string) $parts[1]);
|
||||||
$value = trim(trim($value, '"\''));
|
$value = trim(trim($value, '"\''));
|
||||||
if (in_array($type, $this->validModifiers, true)) {
|
if (in_array($type, $this->validModifiers, true)) {
|
||||||
// filter for valid type
|
// filter for valid type
|
||||||
|
|||||||
Reference in New Issue
Block a user