mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Code cleanup.
This commit is contained in:
@@ -48,8 +48,6 @@ class FixRecurringTransactions extends Command
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
@@ -66,8 +64,6 @@ class FixRecurringTransactions extends Command
|
||||
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
|
||||
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
|
||||
* be called from the handle method instead of using the constructor to initialize the command.
|
||||
*
|
||||
|
||||
*/
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
@@ -75,34 +71,27 @@ class FixRecurringTransactions extends Command
|
||||
$this->userRepos = app(UserRepositoryInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function correctTransactions(): void
|
||||
{
|
||||
$users = $this->userRepos->all();
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$this->processUser($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
private function processUser(User $user): void
|
||||
{
|
||||
$this->recurringRepos->setUser($user);
|
||||
$recurrences = $this->recurringRepos->get();
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
foreach ($recurrences as $recurrence) {
|
||||
$this->processRecurrence($recurrence);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
*/
|
||||
private function processRecurrence(Recurrence $recurrence): void
|
||||
{
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
@@ -111,10 +100,6 @@ class FixRecurringTransactions extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Recurrence $recurrence
|
||||
* @param RecurrenceTransaction $transaction
|
||||
*/
|
||||
private function processTransaction(Recurrence $recurrence, RecurrenceTransaction $transaction): void
|
||||
{
|
||||
$source = $transaction->sourceAccount;
|
||||
@@ -129,7 +114,7 @@ class FixRecurringTransactions extends Command
|
||||
if (null !== $transactionType) {
|
||||
$recurrence->transaction_type_id = $transactionType->id;
|
||||
$recurrence->save();
|
||||
$this->count++;
|
||||
++$this->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user