mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add limit #3150
This commit is contained in:
parent
b207100074
commit
62fd701808
@ -63,7 +63,6 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO add limit
|
||||
* @param AutocompleteRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
@ -78,7 +77,7 @@ class AccountController extends Controller
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$return = [];
|
||||
$result = $repository->searchAccount((string) $query, $types);
|
||||
$result = $repository->searchAccount((string) $query, $types, $data['limit']);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
|
||||
/** @var Account $account */
|
||||
|
@ -559,10 +559,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $types
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchAccount(string $query, array $types): Collection
|
||||
public function searchAccount(string $query, array $types, int $limit): Collection
|
||||
{
|
||||
$dbQuery = $this->user->accounts()
|
||||
->where('active', 1)
|
||||
@ -582,7 +583,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
return $dbQuery->get(['accounts.*']);
|
||||
return $dbQuery->take($limit)->get(['accounts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,10 +276,11 @@ interface AccountRepositoryInterface
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $types
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchAccount(string $query, array $types): Collection;
|
||||
public function searchAccount(string $query, array $types, int $limit): Collection;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
|
@ -214,7 +214,7 @@ class Search implements SearchInterface
|
||||
case 'source':
|
||||
// source can only be asset, liability or revenue account:
|
||||
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE];
|
||||
$accounts = $this->accountRepository->searchAccount($modifier['value'], $searchTypes);
|
||||
$accounts = $this->accountRepository->searchAccount($modifier['value'], $searchTypes, 25);
|
||||
if ($accounts->count() > 0) {
|
||||
$totalAccounts = $accounts->merge($totalAccounts);
|
||||
}
|
||||
@ -223,7 +223,7 @@ class Search implements SearchInterface
|
||||
case 'destination':
|
||||
// source can only be asset, liability or expense account:
|
||||
$searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE];
|
||||
$accounts = $this->accountRepository->searchAccount($modifier['value'], $searchTypes);
|
||||
$accounts = $this->accountRepository->searchAccount($modifier['value'], $searchTypes, 25);
|
||||
if ($accounts->count() > 0) {
|
||||
$totalAccounts = $accounts->merge($totalAccounts);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user