Code cleanup [skip ci]

This commit is contained in:
James Cole
2015-06-03 21:25:11 +02:00
parent 409ec2e086
commit cc7c2e952c
69 changed files with 695 additions and 716 deletions

View File

@@ -2,8 +2,6 @@
namespace FireflyIII\Http\Controllers\Chart;
use Auth;
use Cache;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
@@ -11,7 +9,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use Response;
use Session;
@@ -43,15 +40,14 @@ class AccountController extends Controller
$end->endOfMonth();
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('all');
$chartProperties->addProperty('accounts');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('all');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
$chart->addColumn(trans('firefly.dayOfMonth'), 'date');
@@ -91,7 +87,7 @@ class AccountController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}
@@ -114,15 +110,14 @@ class AccountController extends Controller
$accounts = $repository->getFrontpageAccounts($frontPage);
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('frontpage');
$chartProperties->addProperty('accounts');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('frontpage');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
$index = 1;
@@ -148,7 +143,7 @@ class AccountController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
@@ -174,18 +169,15 @@ class AccountController extends Controller
$today = new Carbon;
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('frontpage');
$chartProperties->addProperty('single');
$chartProperties->addProperty($account->id);
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('frontpage');
$cache->addProperty('single');
$cache->addProperty($account->id);
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
while ($end >= $current) {
$certain = $current < $today;
@@ -197,7 +189,7 @@ class AccountController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}

View File

@@ -14,8 +14,7 @@ use Illuminate\Support\Collection;
use Response;
use Session;
use Steam;
use Cache;
use Log;
/**
* Class BillController
*
@@ -40,14 +39,13 @@ class BillController extends Controller
$chart->addColumn(trans('firefly.minAmount'), 'number');
$chart->addColumn(trans('firefly.billEntry'), 'number');
$chartProperties = new CacheProperties;
$chartProperties->addProperty('single');
$chartProperties->addProperty('bill');
$chartProperties->addProperty($bill->id);
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties;
$cache->addProperty('single');
$cache->addProperty('bill');
$cache->addProperty($bill->id);
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
// get first transaction or today for start:
$results = $repository->getJournals($bill);
@@ -59,7 +57,7 @@ class BillController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}
@@ -79,20 +77,19 @@ class BillController extends Controller
$chart->addColumn(trans('firefly.name'), 'string');
$chart->addColumn(trans('firefly.amount'), 'number');
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('bills');
$chartProperties->addProperty('frontpage');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('bills');
$cache->addProperty('frontpage');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
$bills = $repository->getActiveBills();
$paid = new Collection; // journals.
@@ -163,7 +160,7 @@ class BillController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}

View File

@@ -2,7 +2,6 @@
namespace FireflyIII\Http\Controllers\Chart;
use Cache;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
@@ -11,7 +10,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection;
use Log;
use Navigation;
use Preferences;
use Response;
@@ -45,15 +43,14 @@ class BudgetController extends Controller
$last = Navigation::endOfX($last, $range, $final);
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($first);
$chartProperties->addProperty($last);
$chartProperties->addProperty('budget');
$chartProperties->addProperty('budget');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($first);
$cache->addProperty($last);
$cache->addProperty('budget');
$cache->addProperty('budget');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
while ($first < $last) {
@@ -69,7 +66,7 @@ class BudgetController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}
@@ -90,17 +87,16 @@ class BudgetController extends Controller
$end = $repetition->enddate;
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('budget');
$chartProperties->addProperty('limit');
$chartProperties->addProperty($budget->id);
$chartProperties->addProperty($repetition->id);
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('limit');
$cache->addProperty($budget->id);
$cache->addProperty($repetition->id);
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
$chart->addColumn(trans('firefly.day'), 'date');
$chart->addColumn(trans('firefly.left'), 'number');
@@ -120,7 +116,7 @@ class BudgetController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
@@ -147,15 +143,14 @@ class BudgetController extends Controller
$allEntries = new Collection;
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('budget');
$chartProperties->addProperty('all');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('all');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
/** @var Budget $budget */
@@ -194,7 +189,7 @@ class BudgetController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
@@ -218,15 +213,14 @@ class BudgetController extends Controller
$budgets = $repository->getBudgets();
// chart properties for cache:
$chartProperties = new CacheProperties();
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('budget');
$chartProperties->addProperty('year');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('budget');
$cache->addProperty('year');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
// add columns:
$chart->addColumn(trans('firefly.month'), 'date');
@@ -254,7 +248,7 @@ class BudgetController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);
}

View File

@@ -3,14 +3,12 @@
namespace FireflyIII\Http\Controllers\Chart;
use Cache;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Grumpydictator\Gchart\GChart;
use Log;
use Navigation;
use Preferences;
use Response;
@@ -80,22 +78,21 @@ class CategoryController extends Controller
$end = Session::get('end', Carbon::now()->endOfMonth());
// chart properties for cache:
$chartProperties = new CacheProperties;
$chartProperties->addProperty($start);
$chartProperties->addProperty($end);
$chartProperties->addProperty('category');
$chartProperties->addProperty('frontpage');
if ($chartProperties->has()) {
return Response::json($chartProperties->get());
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('category');
$cache->addProperty('frontpage');
if ($cache->has()) {
return Response::json($cache->get());
}
$md5 = $chartProperties->getMd5();
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
// sort by callback:
uasort(
$set,
function($left, $right) {
function ($left, $right) {
if ($left['sum'] == $right['sum']) {
return 0;
}
@@ -115,7 +112,7 @@ class CategoryController extends Controller
$chart->generate();
$data = $chart->getData();
Cache::forever($md5, $data);
$cache->store($data);
return Response::json($data);