Query optimisations.

This commit is contained in:
James Cole
2015-12-26 09:21:45 +01:00
parent 79392ab656
commit 209116e766
3 changed files with 30 additions and 15 deletions

View File

@@ -147,7 +147,11 @@ class ReportQuery implements ReportQueryInterface
// get everything
$data = $query->get(
['transaction_journals.*', 'transaction_types.type', 'ac_from.name as name', 'ac_from.id as account_id', 'ac_from.encrypted as account_encrypted']
['transaction_journals.*',
'transaction_types.type', 'ac_from.name as name',
't_from.amount as from_amount',
't_to.amount as to_amount',
'ac_from.id as account_id', 'ac_from.encrypted as account_encrypted']
);
$data->each(
@@ -157,15 +161,15 @@ class ReportQuery implements ReportQueryInterface
}
}
);
$data = $data->filter(
function (TransactionJournal $journal) {
if ($journal->amount != 0) {
return $journal;
}
return null;
}
);
// $data = $data->filter(
// function (TransactionJournal $journal) {
// if ($journal->amount != 0) {
// return $journal;
// }
//
// return null;
// }
// );
return $data;
}
@@ -220,7 +224,10 @@ class ReportQuery implements ReportQueryInterface
$query->orderBy('transaction_journals.date');
$data = $query->get( // get everything
['transaction_journals.*', 'transaction_types.type', 'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']
['transaction_journals.*', 'transaction_types.type',
't_from.amount as from_amount',
't_to.amount as to_amount',
'ac_to.name as name', 'ac_to.id as account_id', 'ac_to.encrypted as account_encrypted']
);
$data->each(