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