Small code optimisation.

This commit is contained in:
James Cole 2017-04-22 07:05:44 +02:00
parent e3cd11ec2e
commit beb358f8ee
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 6 additions and 8 deletions

View File

@ -108,6 +108,10 @@ class ChartJsGenerator implements GeneratorInterface
],
'labels' => [],
];
// sort by value, keep keys.
asort($data);
$index = 0;
foreach ($data as $key => $value) {

View File

@ -336,19 +336,13 @@ class AccountController extends Controller
/**
* @param Account $account
* @param string $date
* @param Carbon $start
*
* @return \Illuminate\Http\JsonResponse
* @throws FireflyException
*/
public function period(Account $account, string $date)
public function period(Account $account, Carbon $start)
{
try {
$start = new Carbon($date);
} catch (Exception $e) {
Log::error($e->getMessage());
throw new FireflyException('"' . e($date) . '" does not seem to be a valid date. Should be in the format YYYY-MM-DD');
}
$range = Preferences::get('viewRange', '1M')->data;
$end = Navigation::endOfPeriod($start, $range);
$cache = new CacheProperties();