mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup
This commit is contained in:
@@ -61,7 +61,7 @@ class AccountSearch implements GenericSearchInterface
|
||||
public function search(): Collection
|
||||
{
|
||||
|
||||
$searchQuery = $this->user->accounts()
|
||||
$searchQuery = $this->user->accounts()
|
||||
->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')
|
||||
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->whereIn('account_types.type', $this->types);
|
||||
|
||||
@@ -86,21 +86,21 @@ class OperatorQuerySearch implements SearchInterface
|
||||
private BillRepositoryInterface $billRepository;
|
||||
private BudgetRepositoryInterface $budgetRepository;
|
||||
private CategoryRepositoryInterface $categoryRepository;
|
||||
private TagRepositoryInterface $tagRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private TransactionTypeRepositoryInterface $typeRepository;
|
||||
private User $user;
|
||||
private ParsedQuery $query;
|
||||
private int $page;
|
||||
private int $limit;
|
||||
private array $words;
|
||||
private array $validOperators;
|
||||
private GroupCollectorInterface $collector;
|
||||
private float $startTime;
|
||||
private Collection $modifiers; // obsolete
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private Carbon $date;
|
||||
private int $limit;
|
||||
private Collection $modifiers;
|
||||
private Collection $operators;
|
||||
private string $originalQuery;
|
||||
private Carbon $date;
|
||||
private int $page;
|
||||
private ParsedQuery $query;
|
||||
private float $startTime;
|
||||
private TagRepositoryInterface $tagRepository;
|
||||
private TransactionTypeRepositoryInterface $typeRepository; // obsolete
|
||||
private User $user;
|
||||
private array $validOperators;
|
||||
private array $words;
|
||||
|
||||
/**
|
||||
* OperatorQuerySearch constructor.
|
||||
@@ -146,14 +146,6 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return $this->operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function setDate(Carbon $date): void
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @codeCoverageIgnore
|
||||
@@ -163,24 +155,6 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return implode(' ', $this->words);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWords(): array
|
||||
{
|
||||
return $this->words;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setPage(int $page): void
|
||||
{
|
||||
$this->page = $page;
|
||||
$this->collector->setPage($this->page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @codeCoverageIgnore
|
||||
@@ -231,6 +205,33 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return $this->collector->getPaginatedGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function setDate(Carbon $date): void
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setLimit(int $limit): void
|
||||
{
|
||||
$this->limit = $limit;
|
||||
$this->collector->setLimit($this->limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setPage(int $page): void
|
||||
{
|
||||
$this->page = $page;
|
||||
$this->collector->setPage($this->page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @codeCoverageIgnore
|
||||
@@ -644,6 +645,28 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $operator
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function getRootOperator(string $operator): string
|
||||
{
|
||||
$config = config(sprintf('firefly.search.operators.%s', $operator));
|
||||
if (null === $config) {
|
||||
throw new FireflyException(sprintf('No configuration for search operator "%s"', $operator));
|
||||
}
|
||||
if (true === $config['alias']) {
|
||||
Log::debug(sprintf('"%s" is an alias for "%s", so return that instead.', $operator, $config['alias_for']));
|
||||
|
||||
return $config['alias_for'];
|
||||
}
|
||||
Log::debug(sprintf('"%s" is not an alias.', $operator));
|
||||
|
||||
return $operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* searchDirection: 1 = source (default), 2 = destination
|
||||
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
|
||||
@@ -709,7 +732,6 @@ class OperatorQuerySearch implements SearchInterface
|
||||
$this->collector->$collectorMethod($filtered);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* searchDirection: 1 = source (default), 2 = destination
|
||||
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
|
||||
@@ -787,6 +809,14 @@ class OperatorQuerySearch implements SearchInterface
|
||||
$this->collector->$collectorMethod($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
private function getCashAccount(): Account
|
||||
{
|
||||
return $this->accountRepository->getCashAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@@ -809,28 +839,6 @@ class OperatorQuerySearch implements SearchInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $operator
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function getRootOperator(string $operator): string
|
||||
{
|
||||
$config = config(sprintf('firefly.search.operators.%s', $operator));
|
||||
if (null === $config) {
|
||||
throw new FireflyException(sprintf('No configuration for search operator "%s"', $operator));
|
||||
}
|
||||
if (true === $config['alias']) {
|
||||
Log::debug(sprintf('"%s" is an alias for "%s", so return that instead.', $operator, $config['alias_for']));
|
||||
|
||||
return $config['alias_for'];
|
||||
}
|
||||
Log::debug(sprintf('"%s" is not an alias.', $operator));
|
||||
|
||||
return $operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
@@ -852,19 +860,10 @@ class OperatorQuerySearch implements SearchInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
public function setLimit(int $limit): void
|
||||
public function getWords(): array
|
||||
{
|
||||
$this->limit = $limit;
|
||||
$this->collector->setLimit($this->limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
private function getCashAccount(): Account
|
||||
{
|
||||
return $this->accountRepository->getCashAccount();
|
||||
return $this->words;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,16 +47,6 @@ interface SearchInterface
|
||||
*/
|
||||
public function getWordsAsString(): string;
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
*/
|
||||
public function setPage(int $page): void;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setLimit(int $limit): void;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@@ -77,13 +67,23 @@ interface SearchInterface
|
||||
*/
|
||||
public function searchTransactions(): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function setDate(Carbon $date): void;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setLimit(int $limit): void;
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
*/
|
||||
public function setPage(int $page): void;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user