Skip to content

Firefly III: a personal finances manager

Merge branch 'v6.2' of github.com:firefly-iii/firefly-iii into v6.2

James Cole5751f7e5a323
diff --cc app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php
index 5085aa08ae,4c709009fe..f67cf912b7
--- a/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php
+++ b/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php
@@@ -57,13 -57,13 +57,12 @@@ class ShowController extends Controlle
public function show(TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
- // $piggies = $this->repository->getAll();
- //
- $pageSize = $this->parameters->get('limit');
- $rates = $this->repository->getRates($from, $to);
- $count = $rates->count();
- $rates = $rates->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
- $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $this->parameters->get('page'));
+ $pageSize = $this->parameters->get('limit');
+ $page = $this->parameters->get('page');
+ $rates = $this->repository->getRates($from, $to);
+ $count = $rates->count();
-
+ $rates = $rates->slice(($page - 1) * $pageSize, $pageSize);
+ $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $page);
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
diff --cc app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php
index e89a9d2521,ebeba099f2..8c0d6621db
--- a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php
+++ b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php
@@@ -32,22 -33,23 +33,22 @@@ class ExchangeRateRepository implement
{
use UserGroupTrait;
-
- #[\Override] public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection
+ #[\Override]
+ public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection
{
+ // orderBy('date', 'DESC')->toRawSql();
return
$this->userGroup->currencyExchangeRates()
- ->where(function (Builder $q) use ($from, $to): void {
- $q->where('from_currency_id', $from->id)
- ->orWhere('to_currency_id', $to->id)
- ;
- })
- ->orWhere(function (Builder $q) use ($from, $to): void {
- $q->where('from_currency_id', $to->id)
- ->orWhere('to_currency_id', $from->id)
- ;
- })
- ->orderBy('date', 'DESC')->get()
- ;
+ ->where(function (Builder $q1) use ($from, $to) {
+ $q1->where(function (Builder $q) use ($from, $to) {
+ $q->where('from_currency_id', $from->id)
+ ->where('to_currency_id', $to->id);
+ })->orWhere(function (Builder $q) use ($from, $to) {
+ $q->where('from_currency_id', $to->id)
+ ->where('to_currency_id', $from->id);
+ });
+ })
+ ->orderBy('date', 'DESC')->get(['currency_exchange_rates.*']);
}
}