mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
Cleanup cleanup [skip ci]
This commit is contained in:
@@ -56,16 +56,34 @@ class Cleanup
|
|||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if ($this->auth->guest()) {
|
if ($this->auth->guest()) {
|
||||||
if ($request->ajax()) {
|
|
||||||
return response('Unauthorized.', 401);
|
return response('Unauthorized.', 401);
|
||||||
} else {
|
|
||||||
return redirect()->guest('auth/login');
|
|
||||||
}
|
}
|
||||||
}
|
$count = -1;
|
||||||
$run = env('RUNCLEANUP') == 'true' ? true : false;
|
|
||||||
$count = 0;
|
|
||||||
|
|
||||||
if ($run) {
|
bcscale(0);
|
||||||
|
|
||||||
|
if (env('RUNCLEANUP') == 'true') {
|
||||||
|
$count = 0;
|
||||||
|
$count = bcadd($count, $this->encryptAccountAndBills());
|
||||||
|
$count = bcadd($count, $this->encryptBudgetsAndCategories());
|
||||||
|
$count = bcadd($count, $this->encryptPiggiesAndJournals());
|
||||||
|
$count = bcadd($count, $this->encryptRemindersAndPreferences());
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($count == 0) {
|
||||||
|
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function encryptAccountAndBills()
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
// encrypt account name
|
// encrypt account name
|
||||||
$set = Account::where('encrypted', 0)->take(5)->get();
|
$set = Account::where('encrypted', 0)->take(5)->get();
|
||||||
/** @var Account $entry */
|
/** @var Account $entry */
|
||||||
@@ -98,6 +116,18 @@ class Cleanup
|
|||||||
}
|
}
|
||||||
unset($set, $entry, $match);
|
unset($set, $entry, $match);
|
||||||
|
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function encryptBudgetsAndCategories()
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
// encrypt budget name
|
// encrypt budget name
|
||||||
$set = Budget::where('encrypted', 0)->take(5)->get();
|
$set = Budget::where('encrypted', 0)->take(5)->get();
|
||||||
/** @var Budget $entry */
|
/** @var Budget $entry */
|
||||||
@@ -120,6 +150,17 @@ class Cleanup
|
|||||||
}
|
}
|
||||||
unset($set, $entry, $name);
|
unset($set, $entry, $name);
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function encryptPiggiesAndJournals()
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
|
|
||||||
// encrypt piggy bank name
|
// encrypt piggy bank name
|
||||||
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
|
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
|
||||||
/** @var PiggyBank $entry */
|
/** @var PiggyBank $entry */
|
||||||
@@ -142,6 +183,16 @@ class Cleanup
|
|||||||
}
|
}
|
||||||
unset($set, $entry, $description);
|
unset($set, $entry, $description);
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function encryptRemindersAndPreferences()
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
// encrypt reminder metadata
|
// encrypt reminder metadata
|
||||||
$set = Reminder::where('encrypted', 0)->take(5)->get();
|
$set = Reminder::where('encrypted', 0)->take(5)->get();
|
||||||
/** @var Reminder $entry */
|
/** @var Reminder $entry */
|
||||||
@@ -175,12 +226,7 @@ class Cleanup
|
|||||||
}
|
}
|
||||||
unset($set, $entry, $data);
|
unset($set, $entry, $data);
|
||||||
|
|
||||||
}
|
return $count;
|
||||||
if ($count == 0 && $run) {
|
|
||||||
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user