mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	Some experiments with a cache control thing. [skip ci]
This commit is contained in:
		| @@ -86,6 +86,7 @@ class AccountController extends Controller | |||||||
|         $repository->destroy($account); |         $repository->destroy($account); | ||||||
|  |  | ||||||
|         Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name])); |         Session::flash('success', trans('firefly.' . $typeName . '_deleted', ['name' => $name])); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::to(Session::get('accounts.delete.url')); |         return Redirect::to(Session::get('accounts.delete.url')); | ||||||
|     } |     } | ||||||
| @@ -206,6 +207,7 @@ class AccountController extends Controller | |||||||
|         $account = $repository->store($accountData); |         $account = $repository->store($accountData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'New account "' . $account->name . '" stored!'); |         Session::flash('success', 'New account "' . $account->name . '" stored!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             // set value so create routine will not overwrite URL: |             // set value so create routine will not overwrite URL: | ||||||
| @@ -246,6 +248,7 @@ class AccountController extends Controller | |||||||
|         $repository->update($account, $accountData); |         $repository->update($account, $accountData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Account "' . $account->name . '" updated.'); |         Session::flash('success', 'Account "' . $account->name . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             // set value so edit routine will not overwrite URL: |             // set value so edit routine will not overwrite URL: | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ use FireflyIII\Models\Bill; | |||||||
| use FireflyIII\Models\TransactionJournal; | use FireflyIII\Models\TransactionJournal; | ||||||
| use FireflyIII\Repositories\Bill\BillRepositoryInterface; | use FireflyIII\Repositories\Bill\BillRepositoryInterface; | ||||||
| use Input; | use Input; | ||||||
|  | use Preferences; | ||||||
| use Redirect; | use Redirect; | ||||||
| use Session; | use Session; | ||||||
| use URL; | use URL; | ||||||
| @@ -75,6 +76,7 @@ class BillController extends Controller | |||||||
|         $repository->destroy($bill); |         $repository->destroy($bill); | ||||||
|  |  | ||||||
|         Session::flash('success', 'The bill was deleted.'); |         Session::flash('success', 'The bill was deleted.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::to(Session::get('bills.delete.url')); |         return Redirect::to(Session::get('bills.delete.url')); | ||||||
|  |  | ||||||
| @@ -141,6 +143,7 @@ class BillController extends Controller | |||||||
|  |  | ||||||
|  |  | ||||||
|         Session::flash('success', 'Rescanned everything.'); |         Session::flash('success', 'Rescanned everything.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::to(URL::previous()); |         return Redirect::to(URL::previous()); | ||||||
|     } |     } | ||||||
| @@ -172,6 +175,7 @@ class BillController extends Controller | |||||||
|         $billData = $request->getBillData(); |         $billData = $request->getBillData(); | ||||||
|         $bill     = $repository->store($billData); |         $bill     = $repository->store($billData); | ||||||
|         Session::flash('success', 'Bill "' . e($bill->name) . '" stored.'); |         Session::flash('success', 'Bill "' . e($bill->name) . '" stored.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             // set value so create routine will not overwrite URL: |             // set value so create routine will not overwrite URL: | ||||||
| @@ -198,6 +202,7 @@ class BillController extends Controller | |||||||
|         $bill     = $repository->update($bill, $billData); |         $bill     = $repository->update($bill, $billData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Bill "' . e($bill->name) . '" updated.'); |         Session::flash('success', 'Bill "' . e($bill->name) . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             // set value so edit routine will not overwrite URL: |             // set value so edit routine will not overwrite URL: | ||||||
|   | |||||||
| @@ -49,6 +49,7 @@ class BudgetController extends Controller | |||||||
|         if ($amount == 0) { |         if ($amount == 0) { | ||||||
|             $limitRepetition = null; |             $limitRepetition = null; | ||||||
|         } |         } | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]); |         return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]); | ||||||
|  |  | ||||||
| @@ -102,6 +103,7 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|  |  | ||||||
|         Session::flash('success', 'The  budget "' . e($name) . '" was deleted.'); |         Session::flash('success', 'The  budget "' . e($name) . '" was deleted.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         return Redirect::to(Session::get('budgets.delete.url')); |         return Redirect::to(Session::get('budgets.delete.url')); | ||||||
| @@ -196,6 +198,7 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         $date = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); |         $date = Session::get('start', Carbon::now()->startOfMonth())->format('FY'); | ||||||
|         Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount'))); |         Preferences::set('budgetIncomeTotal' . $date, intval(Input::get('amount'))); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::route('budgets.index'); |         return Redirect::route('budgets.index'); | ||||||
|     } |     } | ||||||
| @@ -242,6 +245,7 @@ class BudgetController extends Controller | |||||||
|         $budget = $repository->store($budgetData); |         $budget = $repository->store($budgetData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'New budget "' . $budget->name . '" stored!'); |         Session::flash('success', 'New budget "' . $budget->name . '" stored!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             // set value so create routine will not overwrite URL: |             // set value so create routine will not overwrite URL: | ||||||
| @@ -272,6 +276,7 @@ class BudgetController extends Controller | |||||||
|         $repository->update($budget, $budgetData); |         $repository->update($budget, $budgetData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Budget "' . $budget->name . '" updated.'); |         Session::flash('success', 'Budget "' . $budget->name . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             // set value so edit routine will not overwrite URL: |             // set value so edit routine will not overwrite URL: | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ use FireflyIII\Models\Category; | |||||||
| use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | ||||||
| use Illuminate\Pagination\LengthAwarePaginator; | use Illuminate\Pagination\LengthAwarePaginator; | ||||||
| use Input; | use Input; | ||||||
|  | use Preferences; | ||||||
| use Redirect; | use Redirect; | ||||||
| use Session; | use Session; | ||||||
| use URL; | use URL; | ||||||
| @@ -77,6 +78,7 @@ class CategoryController extends Controller | |||||||
|         $repository->destroy($category); |         $repository->destroy($category); | ||||||
|  |  | ||||||
|         Session::flash('success', 'The  category "' . e($name) . '" was deleted.'); |         Session::flash('success', 'The  category "' . e($name) . '" was deleted.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::to(Session::get('categories.delete.url')); |         return Redirect::to(Session::get('categories.delete.url')); | ||||||
|     } |     } | ||||||
| @@ -168,6 +170,7 @@ class CategoryController extends Controller | |||||||
|         $category = $repository->store($categoryData); |         $category = $repository->store($categoryData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'New category "' . $category->name . '" stored!'); |         Session::flash('success', 'New category "' . $category->name . '" stored!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             Session::put('categories.create.fromStore', true); |             Session::put('categories.create.fromStore', true); | ||||||
| @@ -195,6 +198,7 @@ class CategoryController extends Controller | |||||||
|         $repository->update($category, $categoryData); |         $repository->update($category, $categoryData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Category "' . $category->name . '" updated.'); |         Session::flash('success', 'Category "' . $category->name . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             Session::put('categories.edit.fromUpdate', true); |             Session::put('categories.edit.fromUpdate', true); | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| namespace FireflyIII\Http\Controllers\Chart; | namespace FireflyIII\Http\Controllers\Chart; | ||||||
|  |  | ||||||
|  | use Auth; | ||||||
| use Cache; | use Cache; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
| @@ -10,11 +11,11 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; | |||||||
| use FireflyIII\Support\ChartProperties; | use FireflyIII\Support\ChartProperties; | ||||||
| use Grumpydictator\Gchart\GChart; | use Grumpydictator\Gchart\GChart; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
|  | use Log; | ||||||
| use Preferences; | use Preferences; | ||||||
| use Response; | use Response; | ||||||
| use Session; | use Session; | ||||||
| use Steam; | use Steam; | ||||||
| use Auth; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class AccountController |  * Class AccountController | ||||||
| @@ -40,6 +41,23 @@ class AccountController extends Controller | |||||||
|         $start = new Carbon($year . '-' . $month . '-01'); |         $start = new Carbon($year . '-' . $month . '-01'); | ||||||
|         $end   = clone $start; |         $end   = clone $start; | ||||||
|         $end->endOfMonth(); |         $end->endOfMonth(); | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('all'); | ||||||
|  |         $chartProperties->addProperty('accounts'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         $chart->addColumn(trans('firefly.dayOfMonth'), 'date'); |         $chart->addColumn(trans('firefly.dayOfMonth'), 'date'); | ||||||
|  |  | ||||||
|         /** @var Collection $accounts */ |         /** @var Collection $accounts */ | ||||||
| @@ -76,7 +94,10 @@ class AccountController extends Controller | |||||||
|         } |         } | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -98,22 +119,17 @@ class AccountController extends Controller | |||||||
|  |  | ||||||
|         // chart properties for cache: |         // chart properties for cache: | ||||||
|         $chartProperties = new ChartProperties(); |         $chartProperties = new ChartProperties(); | ||||||
|         $chartProperties->addProperty(Auth::user()->id); |  | ||||||
|         $chartProperties->addProperty($frontPage); |  | ||||||
|         $chartProperties->addProperty($start); |         $chartProperties->addProperty($start); | ||||||
|         $chartProperties->addProperty($end); |         $chartProperties->addProperty($end); | ||||||
|         $chartProperties->addProperty('frontpage'); |         $chartProperties->addProperty('frontpage'); | ||||||
|         $chartProperties->addProperty('accounts'); |         $chartProperties->addProperty('accounts'); | ||||||
|  |  | ||||||
|         /** @var Account $account */ |  | ||||||
|         foreach($accounts as $account) { |  | ||||||
|             $chartProperties->addProperty($repository->getLastActivity($account)); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         $md5 = $chartProperties->md5(); |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (Cache::has($md5)) { |         if (Cache::has($md5)) { | ||||||
|             return Cache::get($md5); |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -165,6 +181,24 @@ class AccountController extends Controller | |||||||
|         $current = clone $start; |         $current = clone $start; | ||||||
|         $today   = new Carbon; |         $today   = new Carbon; | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('frontpage'); | ||||||
|  |         $chartProperties->addProperty('single'); | ||||||
|  |         $chartProperties->addProperty($account->id); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         while ($end >= $current) { |         while ($end >= $current) { | ||||||
|             $certain = $current < $today; |             $certain = $current < $today; | ||||||
|             $chart->addRow(clone $current, Steam::balance($account, $current), $certain); |             $chart->addRow(clone $current, Steam::balance($account, $current), $certain); | ||||||
| @@ -174,6 +208,9 @@ class AccountController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,12 +8,14 @@ use FireflyIII\Models\Bill; | |||||||
| use FireflyIII\Models\TransactionJournal; | use FireflyIII\Models\TransactionJournal; | ||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Bill\BillRepositoryInterface; | use FireflyIII\Repositories\Bill\BillRepositoryInterface; | ||||||
|  | use FireflyIII\Support\ChartProperties; | ||||||
| use Grumpydictator\Gchart\GChart; | use Grumpydictator\Gchart\GChart; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
| use Response; | use Response; | ||||||
| use Session; | use Session; | ||||||
| use Steam; | use Steam; | ||||||
|  | use Cache; | ||||||
|  | use Log; | ||||||
| /** | /** | ||||||
|  * Class BillController |  * Class BillController | ||||||
|  * |  * | ||||||
| @@ -38,6 +40,18 @@ class BillController extends Controller | |||||||
|         $chart->addColumn(trans('firefly.minAmount'), 'number'); |         $chart->addColumn(trans('firefly.minAmount'), 'number'); | ||||||
|         $chart->addColumn(trans('firefly.billEntry'), 'number'); |         $chart->addColumn(trans('firefly.billEntry'), 'number'); | ||||||
|  |  | ||||||
|  |         $chartProperties = new ChartProperties; | ||||||
|  |         $chartProperties->addProperty('single'); | ||||||
|  |         $chartProperties->addProperty('bill'); | ||||||
|  |         $chartProperties->addProperty($bill->id); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // get first transaction or today for start: |         // get first transaction or today for start: | ||||||
|         $results = $repository->getJournals($bill); |         $results = $repository->getJournals($bill); | ||||||
|         /** @var TransactionJournal $result */ |         /** @var TransactionJournal $result */ | ||||||
| @@ -47,8 +61,10 @@ class BillController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -68,6 +84,22 @@ class BillController extends Controller | |||||||
|  |  | ||||||
|         $start  = Session::get('start', Carbon::now()->startOfMonth()); |         $start  = Session::get('start', Carbon::now()->startOfMonth()); | ||||||
|         $end    = Session::get('end', Carbon::now()->endOfMonth()); |         $end    = Session::get('end', Carbon::now()->endOfMonth()); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('bills'); | ||||||
|  |         $chartProperties->addProperty('frontpage'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $bills  = $repository->getActiveBills(); |         $bills  = $repository->getActiveBills(); | ||||||
|         $paid   = new Collection; // journals. |         $paid   = new Collection; // journals. | ||||||
|         $unpaid = new Collection; // bills |         $unpaid = new Collection; // bills | ||||||
| @@ -133,8 +165,12 @@ class BillController extends Controller | |||||||
|  |  | ||||||
|         $chart->addRow(trans('firefly.unpaid') . ': ' . join(', ', $unpaidDescriptions), $unpaidAmount); |         $chart->addRow(trans('firefly.unpaid') . ': ' . join(', ', $unpaidDescriptions), $unpaidAmount); | ||||||
|         $chart->addRow(trans('firefly.paid') . ': ' . join(', ', $paidDescriptions), $paidAmount); |         $chart->addRow(trans('firefly.paid') . ': ' . join(', ', $paidDescriptions), $paidAmount); | ||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| namespace FireflyIII\Http\Controllers\Chart; | namespace FireflyIII\Http\Controllers\Chart; | ||||||
|  |  | ||||||
| use Auth; | use Cache; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
| use FireflyIII\Models\Budget; | use FireflyIII\Models\Budget; | ||||||
| @@ -11,6 +11,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | |||||||
| use FireflyIII\Support\ChartProperties; | use FireflyIII\Support\ChartProperties; | ||||||
| use Grumpydictator\Gchart\GChart; | use Grumpydictator\Gchart\GChart; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
|  | use Log; | ||||||
| use Navigation; | use Navigation; | ||||||
| use Preferences; | use Preferences; | ||||||
| use Response; | use Response; | ||||||
| @@ -43,6 +44,21 @@ class BudgetController extends Controller | |||||||
|         $final->addYears(2); |         $final->addYears(2); | ||||||
|         $last = Navigation::endOfX($last, $range, $final); |         $last = Navigation::endOfX($last, $range, $final); | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($first); | ||||||
|  |         $chartProperties->addProperty($last); | ||||||
|  |         $chartProperties->addProperty('budget'); | ||||||
|  |         $chartProperties->addProperty('budget'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         while ($first < $last) { |         while ($first < $last) { | ||||||
|             $end = Navigation::addPeriod($first, $range, 0); |             $end = Navigation::addPeriod($first, $range, 0); | ||||||
|  |  | ||||||
| @@ -55,7 +71,10 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -73,6 +92,22 @@ class BudgetController extends Controller | |||||||
|         $start = clone $repetition->startdate; |         $start = clone $repetition->startdate; | ||||||
|         $end   = $repetition->enddate; |         $end   = $repetition->enddate; | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('budget'); | ||||||
|  |         $chartProperties->addProperty('limit'); | ||||||
|  |         $chartProperties->addProperty($budget->id); | ||||||
|  |         $chartProperties->addProperty($repetition->id); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $chart->addColumn(trans('firefly.day'), 'date'); |         $chart->addColumn(trans('firefly.day'), 'date'); | ||||||
|         $chart->addColumn(trans('firefly.left'), 'number'); |         $chart->addColumn(trans('firefly.left'), 'number'); | ||||||
|  |  | ||||||
| @@ -90,7 +125,10 @@ class BudgetController extends Controller | |||||||
|         } |         } | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -114,6 +152,20 @@ class BudgetController extends Controller | |||||||
|         $end        = Session::get('end', Carbon::now()->endOfMonth()); |         $end        = Session::get('end', Carbon::now()->endOfMonth()); | ||||||
|         $allEntries = new Collection; |         $allEntries = new Collection; | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('budget'); | ||||||
|  |         $chartProperties->addProperty('all'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         /** @var Budget $budget */ |         /** @var Budget $budget */ | ||||||
|         foreach ($budgets as $budget) { |         foreach ($budgets as $budget) { | ||||||
| @@ -150,7 +202,10 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -171,6 +226,21 @@ class BudgetController extends Controller | |||||||
|         $shared  = $shared == 'shared' ? true : false; |         $shared  = $shared == 'shared' ? true : false; | ||||||
|         $budgets = $repository->getBudgets(); |         $budgets = $repository->getBudgets(); | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties(); | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('budget'); | ||||||
|  |         $chartProperties->addProperty('year'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // add columns: |         // add columns: | ||||||
|         $chart->addColumn(trans('firefly.month'), 'date'); |         $chart->addColumn(trans('firefly.month'), 'date'); | ||||||
|         foreach ($budgets as $budget) { |         foreach ($budgets as $budget) { | ||||||
| @@ -196,6 +266,9 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,11 +3,14 @@ | |||||||
| namespace FireflyIII\Http\Controllers\Chart; | namespace FireflyIII\Http\Controllers\Chart; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use Cache; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
| use FireflyIII\Models\Category; | use FireflyIII\Models\Category; | ||||||
| use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | ||||||
|  | use FireflyIII\Support\ChartProperties; | ||||||
| use Grumpydictator\Gchart\GChart; | use Grumpydictator\Gchart\GChart; | ||||||
|  | use Log; | ||||||
| use Navigation; | use Navigation; | ||||||
| use Preferences; | use Preferences; | ||||||
| use Response; | use Response; | ||||||
| @@ -75,6 +78,22 @@ class CategoryController extends Controller | |||||||
|  |  | ||||||
|         $start = Session::get('start', Carbon::now()->startOfMonth()); |         $start = Session::get('start', Carbon::now()->startOfMonth()); | ||||||
|         $end   = Session::get('end', Carbon::now()->endOfMonth()); |         $end   = Session::get('end', Carbon::now()->endOfMonth()); | ||||||
|  |  | ||||||
|  |         // chart properties for cache: | ||||||
|  |         $chartProperties = new ChartProperties; | ||||||
|  |         $chartProperties->addProperty($start); | ||||||
|  |         $chartProperties->addProperty($end); | ||||||
|  |         $chartProperties->addProperty('category'); | ||||||
|  |         $chartProperties->addProperty('frontpage'); | ||||||
|  |         $md5 = $chartProperties->md5(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         if (Cache::has($md5)) { | ||||||
|  |             Log::debug('Successfully returned cached chart [' . $md5 . '].'); | ||||||
|  |  | ||||||
|  |             return Response::json(Cache::get($md5)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $set   = $repository->getCategoriesAndExpensesCorrected($start, $end); |         $set   = $repository->getCategoriesAndExpensesCorrected($start, $end); | ||||||
|  |  | ||||||
|         // sort by callback: |         // sort by callback: | ||||||
| @@ -99,7 +118,10 @@ class CategoryController extends Controller | |||||||
|  |  | ||||||
|         $chart->generate(); |         $chart->generate(); | ||||||
|  |  | ||||||
|         return Response::json($chart->getData()); |         $data = $chart->getData(); | ||||||
|  |         Cache::forever($md5, $data); | ||||||
|  |  | ||||||
|  |         return Response::json($data); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -59,6 +59,7 @@ class CurrencyController extends Controller | |||||||
|     { |     { | ||||||
|  |  | ||||||
|         Preferences::set('currencyPreference', $currency->code); |         Preferences::set('currencyPreference', $currency->code); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         Session::flash('success', $currency->name . ' is now the default currency.'); |         Session::flash('success', $currency->name . ' is now the default currency.'); | ||||||
|         Cache::forget('FFCURRENCYSYMBOL'); |         Cache::forget('FFCURRENCYSYMBOL'); | ||||||
| @@ -170,6 +171,7 @@ class CurrencyController extends Controller | |||||||
|         if (Auth::user()->hasRole('owner')) { |         if (Auth::user()->hasRole('owner')) { | ||||||
|             $currency = $repository->store($data); |             $currency = $repository->store($data); | ||||||
|             Session::flash('success', 'Currency "' . $currency->name . '" created'); |             Session::flash('success', 'Currency "' . $currency->name . '" created'); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
| @@ -198,6 +200,7 @@ class CurrencyController extends Controller | |||||||
|             $currency = $repository->update($currency, $data); |             $currency = $repository->update($currency, $data); | ||||||
|         } |         } | ||||||
|         Session::flash('success', 'Currency "' . e($currency->name) . '" updated.'); |         Session::flash('success', 'Currency "' . e($currency->name) . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ use Config; | |||||||
| use FireflyIII\Http\Requests\NewUserFormRequest; | use FireflyIII\Http\Requests\NewUserFormRequest; | ||||||
| use FireflyIII\Models\AccountMeta; | use FireflyIII\Models\AccountMeta; | ||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
|  | use Preferences; | ||||||
| use Redirect; | use Redirect; | ||||||
| use Session; | use Session; | ||||||
| use View; | use View; | ||||||
| @@ -113,6 +114,7 @@ class NewUserController extends Controller | |||||||
|  |  | ||||||
|         } |         } | ||||||
|         Session::flash('success', 'New account(s) created!'); |         Session::flash('success', 'New account(s) created!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::route('home'); |         return Redirect::route('home'); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; | |||||||
| use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; | use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
| use Input; | use Input; | ||||||
|  | use Preferences; | ||||||
| use Redirect; | use Redirect; | ||||||
| use Session; | use Session; | ||||||
| use Steam; | use Steam; | ||||||
| @@ -108,6 +109,7 @@ class PiggyBankController extends Controller | |||||||
|  |  | ||||||
|  |  | ||||||
|         Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.'); |         Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.'); | ||||||
|  |         Preferences::mark(); | ||||||
|         $repository->destroy($piggyBank); |         $repository->destroy($piggyBank); | ||||||
|  |  | ||||||
|         return Redirect::to(Session::get('piggy-banks.delete.url')); |         return Redirect::to(Session::get('piggy-banks.delete.url')); | ||||||
| @@ -208,6 +210,7 @@ class PiggyBankController extends Controller | |||||||
|         // set all users piggy banks to zero: |         // set all users piggy banks to zero: | ||||||
|         $repository->reset(); |         $repository->reset(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (is_array($data)) { |         if (is_array($data)) { | ||||||
|             foreach ($data as $order => $id) { |             foreach ($data as $order => $id) { | ||||||
|                 $repository->setOrder(intval($id), (intval($order) + 1)); |                 $repository->setOrder(intval($id), (intval($order) + 1)); | ||||||
| @@ -240,6 +243,7 @@ class PiggyBankController extends Controller | |||||||
|             $repository->createEvent($piggyBank, $amount); |             $repository->createEvent($piggyBank, $amount); | ||||||
|  |  | ||||||
|             Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); |             Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); | ||||||
|  |             Preferences::mark(); | ||||||
|         } else { |         } else { | ||||||
|             Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); |             Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); | ||||||
|         } |         } | ||||||
| @@ -268,6 +272,7 @@ class PiggyBankController extends Controller | |||||||
|             $repository->createEvent($piggyBank, $amount * -1); |             $repository->createEvent($piggyBank, $amount * -1); | ||||||
|  |  | ||||||
|             Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); |             Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); | ||||||
|  |             Preferences::mark(); | ||||||
|         } else { |         } else { | ||||||
|             Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); |             Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); | ||||||
|         } |         } | ||||||
| @@ -328,6 +333,7 @@ class PiggyBankController extends Controller | |||||||
|         $piggyBank = $repository->store($piggyBankData); |         $piggyBank = $repository->store($piggyBankData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Stored piggy bank "' . e($piggyBank->name) . '".'); |         Session::flash('success', 'Stored piggy bank "' . e($piggyBank->name) . '".'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             Session::put('piggy-banks.create.fromStore', true); |             Session::put('piggy-banks.create.fromStore', true); | ||||||
| @@ -362,6 +368,7 @@ class PiggyBankController extends Controller | |||||||
|         $piggyBank = $repository->update($piggyBank, $piggyBankData); |         $piggyBank = $repository->update($piggyBank, $piggyBankData); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".'); |         Session::flash('success', 'Updated piggy bank "' . e($piggyBank->name) . '".'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             Session::put('piggy-banks.edit.fromUpdate', true); |             Session::put('piggy-banks.edit.fromUpdate', true); | ||||||
|   | |||||||
| @@ -77,6 +77,7 @@ class PreferencesController extends Controller | |||||||
|  |  | ||||||
|  |  | ||||||
|         Session::flash('success', 'Preferences saved!'); |         Session::flash('success', 'Preferences saved!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::route('preferences'); |         return Redirect::route('preferences'); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -106,6 +106,7 @@ class TagController extends Controller | |||||||
|         $repository->destroy($tag); |         $repository->destroy($tag); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.'); |         Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Redirect::to(route('tags.index')); |         return Redirect::to(route('tags.index')); | ||||||
|     } |     } | ||||||
| @@ -226,6 +227,7 @@ class TagController extends Controller | |||||||
|         $repository->store($data); |         $repository->store($data); | ||||||
|  |  | ||||||
|         Session::flash('success', 'The tag has been created!'); |         Session::flash('success', 'The tag has been created!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             // set value so create routine will not overwrite URL: |             // set value so create routine will not overwrite URL: | ||||||
| @@ -271,6 +273,7 @@ class TagController extends Controller | |||||||
|         $repository->update($tag, $data); |         $repository->update($tag, $data); | ||||||
|  |  | ||||||
|         Session::flash('success', 'Tag "' . e($data['tag']) . '" updated.'); |         Session::flash('success', 'Tag "' . e($data['tag']) . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             // set value so edit routine will not overwrite URL: |             // set value so edit routine will not overwrite URL: | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ use FireflyIII\Models\TransactionJournal; | |||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | ||||||
| use Input; | use Input; | ||||||
|  | use Preferences; | ||||||
| use Redirect; | use Redirect; | ||||||
| use Response; | use Response; | ||||||
| use Session; | use Session; | ||||||
| @@ -104,6 +105,8 @@ class TransactionController extends Controller | |||||||
|  |  | ||||||
|         $repository->delete($transactionJournal); |         $repository->delete($transactionJournal); | ||||||
|  |  | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         // redirect to previous URL: |         // redirect to previous URL: | ||||||
|         return Redirect::to(Session::get('transactions.delete.url')); |         return Redirect::to(Session::get('transactions.delete.url')); | ||||||
|     } |     } | ||||||
| @@ -235,6 +238,7 @@ class TransactionController extends Controller | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         return Response::json([true]); |         return Response::json([true]); | ||||||
|  |  | ||||||
| @@ -281,6 +285,7 @@ class TransactionController extends Controller | |||||||
|         $repository->deactivateReminder($request->get('reminder_id')); |         $repository->deactivateReminder($request->get('reminder_id')); | ||||||
|  |  | ||||||
|         Session::flash('success', 'New transaction "' . $journal->description . '" stored!'); |         Session::flash('success', 'New transaction "' . $journal->description . '" stored!'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('create_another')) === 1) { |         if (intval(Input::get('create_another')) === 1) { | ||||||
|             // set value so create routine will not overwrite URL: |             // set value so create routine will not overwrite URL: | ||||||
| @@ -312,6 +317,7 @@ class TransactionController extends Controller | |||||||
|         // update, get events by date and sort DESC |         // update, get events by date and sort DESC | ||||||
|  |  | ||||||
|         Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.'); |         Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.'); | ||||||
|  |         Preferences::mark(); | ||||||
|  |  | ||||||
|         if (intval(Input::get('return_to_edit')) === 1) { |         if (intval(Input::get('return_to_edit')) === 1) { | ||||||
|             // set value so edit routine will not overwrite URL: |             // set value so edit routine will not overwrite URL: | ||||||
|   | |||||||
| @@ -3,9 +3,11 @@ | |||||||
| namespace FireflyIII\Support; | namespace FireflyIII\Support; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | use Auth; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| use Illuminate\Database\Eloquent\Collection as EloquentCollection; | use Illuminate\Database\Eloquent\Collection as EloquentCollection; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
|  | use Preferences; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class ChartProperties |  * Class ChartProperties | ||||||
| @@ -24,6 +26,8 @@ class ChartProperties | |||||||
|     public function __construct() |     public function __construct() | ||||||
|     { |     { | ||||||
|         $this->properties = new Collection; |         $this->properties = new Collection; | ||||||
|  |         $this->addProperty(Auth::user()->id); | ||||||
|  |         $this->addProperty(Preferences::lastActivity()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -41,25 +45,33 @@ class ChartProperties | |||||||
|     public function md5() |     public function md5() | ||||||
|     { |     { | ||||||
|         $string = ''; |         $string = ''; | ||||||
|  |         //Log::debug('--- building string ---'); | ||||||
|         foreach ($this->properties as $property) { |         foreach ($this->properties as $property) { | ||||||
|  |  | ||||||
|             if ($property instanceof Collection || $property instanceof EloquentCollection) { |             if ($property instanceof Collection || $property instanceof EloquentCollection) { | ||||||
|                 $string .= print_r($property->toArray(), true); |                 $string .= print_r($property->toArray(), true); | ||||||
|  |                 //                Log::debug('added collection (size=' . $property->count() . ')'); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             if ($property instanceof Carbon) { |             if ($property instanceof Carbon) { | ||||||
|                 $string .= $property->toRfc3339String(); |                 $string .= $property->toRfc3339String(); | ||||||
|  |                 //                Log::debug('Added time: ' . $property->toRfc3339String()); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             if (is_object($property)) { |             if (is_object($property)) { | ||||||
|                 $string .= $property->__toString(); |                 $string .= $property->__toString(); | ||||||
|  |                 //                Log::debug('Added object of class ' . get_class($property)); | ||||||
|             } |             } | ||||||
|             if (is_array($property)) { |             if (is_array($property)) { | ||||||
|                 $string .= print_r($property, true); |                 $string .= print_r($property, true); | ||||||
|  |                 //                Log::debug('Added array (size=' . count($property) . ')'); | ||||||
|             } |             } | ||||||
|             $string .= (string)$property; |             $string .= (string)$property; | ||||||
|  |             //            Log::debug('Added cast to string: ' . $property); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         //        Log::debug('--- done building string ---'); | ||||||
|  |  | ||||||
|         return md5($string); |         return md5($string); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -4,7 +4,7 @@ namespace FireflyIII\Support; | |||||||
|  |  | ||||||
| use Auth; | use Auth; | ||||||
| use FireflyIII\Models\Preference; | use FireflyIII\Models\Preference; | ||||||
|  | use Log; | ||||||
| /** | /** | ||||||
|  * Class Preferences |  * Class Preferences | ||||||
|  * |  * | ||||||
| @@ -12,6 +12,25 @@ use FireflyIII\Models\Preference; | |||||||
|  */ |  */ | ||||||
| class Preferences | class Preferences | ||||||
| { | { | ||||||
|  |     /** | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function lastActivity() | ||||||
|  |     { | ||||||
|  |         $preference = $this->get('lastActivity', microtime())->data; | ||||||
|  |  | ||||||
|  |         return md5($preference); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|  |     public function mark() { | ||||||
|  |         Log::debug('MARK!'); | ||||||
|  |         $this->set('lastActivity',microtime()); | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @param      $name |      * @param      $name | ||||||
|      * @param null $default |      * @param null $default | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user