Optimised queries.

This commit is contained in:
James Cole
2015-12-27 20:07:49 +01:00
parent cd2be8c1a4
commit bc59f2db0d
2 changed files with 30 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
namespace FireflyIII\Generator\Chart\Bill;
use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
/**
@@ -64,11 +65,15 @@ class ChartJsBillChartGenerator implements BillChartGenerator
$minAmount = [];
$maxAmount = [];
$actualAmount = [];
/** @var TransactionJournal $entry */
foreach ($entries as $entry) {
$data['labels'][] = $entry->date->formatLocalized($format);
$minAmount[] = round($bill->amount_min, 2);
$maxAmount[] = round($bill->amount_max, 2);
$actualAmount[] = round(($entry->amount * -1), 2);
/*
* journalAmount has been collected in BillRepository::getJournals
*/
$actualAmount[] = round(($entry->journalAmount * -1), 2);
}
$data['datasets'][] = [