Telemetry cron job.

This commit is contained in:
James Cole
2020-03-21 21:32:17 +01:00
parent 9d7fb0efe1
commit a97d7058ff
3 changed files with 302 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use FireflyIII\Support\Cronjobs\TelemetryCronjob;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Log;
@@ -92,6 +93,17 @@ class Cron extends Command
$this->error($e->getMessage());
}
/*
* Fire telemetry cron job (disabled):
*/
try {
//$this->telemetryCronJob($force, $date);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->error($e->getMessage());
}
$this->info('More feedback on the cron jobs can be found in the log files.');
// app('telemetry')->feature('executed-command', $this->signature);
@@ -150,4 +162,34 @@ class Cron extends Command
$this->line('The recurring transaction cron job fired successfully.');
}
}
/**
* @param bool $force
* @param Carbon|null $date
*/
private function telemetryCronJob(bool $force, ?Carbon $date): void
{
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
// if not configured to do anything with telemetry, do nothing.
return;
}
$telemetry = new TelemetryCronJob;
$telemetry->setForce($force);
// set date in cron job:
if (null !== $date) {
$telemetry->setDate($date);
}
$result = $telemetry->fire();
if (false === $result) {
$this->line('The telemetry cron job did not fire.');
}
if (true === $result) {
$this->line('The telemetry cron job fired successfully.');
}
}
}