Various code cleanup.

This commit is contained in:
James Cole
2021-04-06 08:51:27 +02:00
parent d32446b171
commit 5ceef2e9c3
47 changed files with 161 additions and 557 deletions

View File

@@ -65,9 +65,8 @@ class Cron extends Command
$date = null;
try {
$date = new Carbon($this->option('date'));
} catch (InvalidArgumentException | Exception $e) {
} catch (InvalidArgumentException $e) {
$this->error(sprintf('"%s" is not a valid date', $this->option('date')));
$e->getMessage();
}
$force = (bool)$this->option('force');
@@ -127,13 +126,15 @@ class Cron extends Command
$recurring->setDate($date);
}
$result = $recurring->fire();
if (false === $result) {
$this->line('The recurring transaction cron job did not fire.');
$recurring->fire();
if($recurring->jobErrored) {
$this->error(sprintf('Error in "create recurring transactions" cron: %s', $recurring->message));
}
if (true === $result) {
$this->line('The recurring transaction cron job fired successfully.');
if($recurring->jobFired) {
$this->error(sprintf('"Create recurring transactions" cron fired: %s', $recurring->message));
}
if($recurring->jobSucceeded) {
$this->error(sprintf('"Create recurring transactions" cron ran with success: %s', $recurring->message));
}
}
@@ -142,7 +143,6 @@ class Cron extends Command
* @param Carbon|null $date
*
* @throws FireflyException
* @throws Exception
*/
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
{
@@ -153,13 +153,16 @@ class Cron extends Command
$autoBudget->setDate($date);
}
$result = $autoBudget->fire();
$autoBudget->fire();
if (false === $result) {
$this->line('The auto budget cron job did not fire.');
if($autoBudget->jobErrored) {
$this->error(sprintf('Error in "create auto budgets" cron: %s', $autoBudget->message));
}
if (true === $result) {
$this->line('The auto budget cron job fired successfully.');
if($autoBudget->jobFired) {
$this->error(sprintf('"Create auto budgets" cron fired: %s', $autoBudget->message));
}
if($autoBudget->jobSucceeded) {
$this->error(sprintf('"Create auto budgets" cron ran with success: %s', $autoBudget->message));
}
}
@@ -167,6 +170,8 @@ class Cron extends Command
/**
* @param bool $force
* @param Carbon|null $date
*
* @throws FireflyException
*/
private function telemetryCronJob(bool $force, ?Carbon $date): void
{
@@ -182,13 +187,16 @@ class Cron extends Command
$telemetry->setDate($date);
}
$result = $telemetry->fire();
$telemetry->fire();
if (false === $result) {
$this->line('The telemetry cron job did not fire.');
if($telemetry->jobErrored) {
$this->error(sprintf('Error in "send telemetry" cron: %s', $telemetry->message));
}
if (true === $result) {
$this->line('The telemetry cron job fired successfully.');
if($telemetry->jobFired) {
$this->error(sprintf('"Send telemetry" cron fired: %s', $telemetry->message));
}
if($telemetry->jobSucceeded) {
$this->error(sprintf('"Send telemetry" cron ran with success: %s', $telemetry->message));
}
}