cleanup: Commands are a lot less verbal and report better on success / failue

This commit is contained in:
James Cole
2023-06-02 07:36:17 +02:00
parent 1e1497ff4e
commit dcf71c6fdf
60 changed files with 1108 additions and 1698 deletions

View File

@@ -37,22 +37,11 @@ use Illuminate\Console\Command;
*/
class FixRecurringTransactions extends Command
{
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fixes recurring transactions with the wrong transaction type.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:fix-recurring-transactions';
/** @var RecurringRepositoryInterface */
private $recurringRepos;
/** @var UserRepositoryInterface */
private $userRepos;
protected $description = 'Fixes recurring transactions with the wrong transaction type.';
protected $signature = 'firefly-iii:fix-recurring-transactions';
private int $count = 0;
private RecurringRepositoryInterface $recurringRepos;
private UserRepositoryInterface $userRepos;
/**
* Execute the console command.
@@ -61,11 +50,11 @@ class FixRecurringTransactions extends Command
*/
public function handle(): int
{
$start = microtime(true);
$this->stupidLaravel();
$this->correctTransactions();
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Corrected recurring transactions in %s seconds.', $end));
if (0 === $this->count) {
$this->info('Correct: all recurring transactions are OK.');
}
return 0;
}
@@ -111,6 +100,7 @@ class FixRecurringTransactions extends Command
if (null !== $transactionType) {
$recurrence->transaction_type_id = $transactionType->id;
$recurrence->save();
$this->count++;
}
}
}