mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Optimized decryption.
This commit is contained in:
parent
566fadad15
commit
e000fb5d80
@ -4,10 +4,12 @@ namespace FireflyIII\Helpers\Report;
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
@ -236,7 +238,8 @@ class ReportQuery implements ReportQueryInterface
|
||||
}
|
||||
$query->groupBy('t_from.account_id')->orderBy('transaction_journals.date');
|
||||
|
||||
return $query->get(
|
||||
// get everything, decrypt and return
|
||||
$data = $query->get(
|
||||
['transaction_journals.id',
|
||||
'transaction_journals.description',
|
||||
'transaction_journals.encrypted',
|
||||
@ -248,6 +251,15 @@ class ReportQuery implements ReportQueryInterface
|
||||
'ac_from.encrypted as account_encrypted'
|
||||
]
|
||||
);
|
||||
|
||||
$data->each(
|
||||
function (Model $object) {
|
||||
// $object->description = intval($object->encrypted);
|
||||
$object->name = intval($object->account_encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,7 +337,15 @@ class ReportQuery implements ReportQueryInterface
|
||||
->groupBy('categories.id')
|
||||
->orderBy('amount');
|
||||
|
||||
return $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
|
||||
$data = $query->get(['categories.id', 'categories.encrypted', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
|
||||
// decrypt data:
|
||||
$data->each(
|
||||
function (Model $object) {
|
||||
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
@ -372,7 +392,16 @@ class ReportQuery implements ReportQueryInterface
|
||||
->groupBy('t_to.account_id')
|
||||
->orderBy('amount', 'DESC');
|
||||
|
||||
return $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `amount`')]);
|
||||
$data = $query->get(['t_to.account_id as id', 'ac_to.name as name', 'ac_to.encrypted', DB::Raw('SUM(t_to.amount) as `amount`')]);
|
||||
|
||||
// decrypt
|
||||
$data->each(
|
||||
function (Model $object) {
|
||||
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,9 +443,17 @@ class ReportQuery implements ReportQueryInterface
|
||||
|
||||
$query->groupBy('t_from.account_id')->orderBy('amount');
|
||||
|
||||
return $query->get(
|
||||
$data = $query->get(
|
||||
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `amount`')]
|
||||
);
|
||||
// decrypt
|
||||
$data->each(
|
||||
function (Model $object) {
|
||||
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
|
||||
}
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,12 +270,6 @@ class ReportController extends Controller
|
||||
$categories = Steam::makeArray($result);
|
||||
|
||||
|
||||
// loop and decrypt if necessary:
|
||||
foreach ($categories as $index => $category) {
|
||||
$categories[$index]['name']
|
||||
= intval($categories[$index]['encrypted']) == 1 ? Crypt::decrypt($categories[$index]['name']) : $categories[$index]['name'];
|
||||
}
|
||||
|
||||
// all transfers
|
||||
if ($showSharedReports === false) {
|
||||
$result = $this->query->sharedExpensesByCategory($start, $end);
|
||||
|
@ -22,11 +22,7 @@
|
||||
@foreach($income as $entry)
|
||||
<tr>
|
||||
<td>
|
||||
@if($entry->encrypted === true)
|
||||
<a href="{{route('transactions.show',$entry->id)}}" title="{{{Crypt::decrypt($entry->description)}}}">{{{Crypt::decrypt($entry->description)}}}</a>
|
||||
@else
|
||||
<a href="{{route('transactions.show',$entry->id)}}" title="{{{$entry->description}}}">{{{$entry->description}}}</a>
|
||||
@endif
|
||||
<a href="{{route('transactions.show',$entry->id)}}" title="{{{$entry->description}}}">{{{$entry->description}}}</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php $tableSum += floatval($entry->amount);?>
|
||||
@ -44,11 +40,7 @@
|
||||
{{$entry->date->format('j F Y')}}
|
||||
</td>
|
||||
<td>
|
||||
@if(intval($entry->account_encrypted) == 1)
|
||||
<a href="{{route('accounts.show',$entry->account_id)}}">{{{Crypt::decrypt($entry->name)}}}</a>
|
||||
@else
|
||||
<a href="{{route('accounts.show',$entry->account_id)}}">{{{$entry->name}}}</a>
|
||||
@endif
|
||||
<a href="{{route('accounts.show',$entry->account_id)}}">{{{$entry->name}}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@ -73,15 +65,12 @@
|
||||
@foreach($expenses as $id => $expense)
|
||||
<?php
|
||||
$sum += floatval($expense['amount']);
|
||||
$name = isset($expense['encrypted']) && intval($expense['encrypted']) ==1 ? Crypt::decrypt($expense['name']) :$expense['name'];
|
||||
//var_dump($expense);
|
||||
?>
|
||||
<tr>
|
||||
@if($id > 0)
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$name}}}</a></td>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$expense['name']}}}</a></td>
|
||||
@else
|
||||
|
||||
<td><em>{{{$expense['name']}}}</em></td>
|
||||
<td><em>{{{$expense['name']}}}</em></td>
|
||||
@endif
|
||||
<td>{!! Amount::format($expense['amount']) !!}</td>
|
||||
</tr>
|
||||
|
@ -128,10 +128,9 @@
|
||||
@foreach($groupedIncomes as $income)
|
||||
<?php
|
||||
$sum += floatval($income->amount)*-1;
|
||||
$name = intval($income->encrypted) == 1 ? Crypt::decrypt($income->name) : $income->name;
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$income->account_id)}}">{{{$name}}}</a></td>
|
||||
<td><a href="{{route('accounts.show',$income->account_id)}}">{{{$income->name}}}</a></td>
|
||||
<td>{!! Amount::format(floatval($income->amount)*-1) !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@ -151,11 +150,8 @@
|
||||
<table class="table">
|
||||
<?php $sum = 0;?>
|
||||
@foreach($groupedExpenses as $id => $expense)
|
||||
<?php
|
||||
$name = intval($expense['encrypted']) == 1 ? Crypt::decrypt($expense['name']) : $expense['name'];
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$name}}}</a></td>
|
||||
<td><a href="{{route('accounts.show',$id)}}">{{{$expense['name']}}}</a></td>
|
||||
<td>{!! Amount::format(floatval($expense['amount'])*-1) !!}</td>
|
||||
</tr>
|
||||
<?php $sum += floatval($expense['amount'])*-1;?>
|
||||
|
Loading…
Reference in New Issue
Block a user