mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Code cleanup
This commit is contained in:
@@ -25,6 +25,7 @@ namespace FireflyIII\Support\Cronjobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class AbstractCronjob
|
||||
*
|
||||
@@ -34,12 +35,10 @@ abstract class AbstractCronjob
|
||||
{
|
||||
/** @var int */
|
||||
public $timeBetweenRuns = 43200;
|
||||
|
||||
/** @var bool */
|
||||
protected $force;
|
||||
|
||||
/** @var Carbon */
|
||||
protected $date;
|
||||
/** @var bool */
|
||||
protected $force;
|
||||
|
||||
/**
|
||||
* AbstractCronjob constructor.
|
||||
@@ -52,15 +51,10 @@ abstract class AbstractCronjob
|
||||
$this->date = today(config('app.timezone'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @return bool
|
||||
*/
|
||||
public function setForce(bool $force): void
|
||||
{
|
||||
$this->force = $force;
|
||||
}
|
||||
abstract public function fire(): bool;
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
@@ -71,8 +65,11 @@ abstract class AbstractCronjob
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param bool $force
|
||||
*/
|
||||
abstract public function fire(): bool;
|
||||
public function setForce(bool $force): void
|
||||
{
|
||||
$this->force = $force;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class RecurringCronjob extends AbstractCronjob
|
||||
$job->setForce($this->force);
|
||||
$job->handle();
|
||||
app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));
|
||||
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)',$this->date->format('Y-m-d H:i:s'),(int)$this->date->format('U')));
|
||||
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
|
||||
Log::info('Done with recurring cron job task.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +45,14 @@ class TelemetryCronjob extends AbstractCronjob
|
||||
// do not fire if telemetry is disabled.
|
||||
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
|
||||
Log::warning('Telemetry is disabled. The cron job will do nothing.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** @var Configuration $config */
|
||||
$config = app('fireflyconfig')->get('last_tm_job', 0);
|
||||
$lastTime = (int) $config->data;
|
||||
$lastTime = (int)$config->data;
|
||||
$diff = time() - $lastTime;
|
||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), true);
|
||||
if (0 === $lastTime) {
|
||||
@@ -98,7 +99,7 @@ class TelemetryCronjob extends AbstractCronjob
|
||||
|
||||
// TODO remove old, submitted telemetry data.
|
||||
|
||||
app('fireflyconfig')->set('last_tm_job', (int) $this->date->format('U'));
|
||||
app('fireflyconfig')->set('last_tm_job', (int)$this->date->format('U'));
|
||||
Log::info('Done with telemetry cron job task.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user