Alert if cron job isn't running.

This commit is contained in:
James Cole 2018-08-13 19:07:46 +02:00
parent 6c9eb1b699
commit 7327941c77
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 24 additions and 2 deletions

View File

@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Recurrence;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
use FireflyIII\Transformers\RecurrenceTransformer;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
@ -41,6 +42,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
class IndexController extends Controller
{
use GetConfigurationData;
/** @var RecurringRepositoryInterface Recurring repository */
private $recurring;
@ -97,6 +99,8 @@ class IndexController extends Controller
$paginator = new LengthAwarePaginator($recurring, $total, $pageSize, $page);
$paginator->setPath(route('recurring.index'));
$this->verifyRecurringCronJob();
return view('recurring.index', compact('paginator', 'page', 'pageSize', 'total'));
}

View File

@ -33,6 +33,7 @@ use Log;
*/
trait GetConfigurationData
{
/**
* All packages that are installed.
*
@ -247,4 +248,21 @@ trait GetConfigurationData
return false;
}
/**
*
*/
protected function verifyRecurringCronJob(): void
{
$config = app('fireflyconfig')->get('last_rt_job', 0);
$lastTime = (int)$config->data;
$now = time();
if (0 === $lastTime) {
request()->session()->flash('info', trans('firefly.recurring_never_cron'));
return;
}
if($now - $lastTime > 129600) {
request()->session()->flash('warning', trans('firefly.recurring_cron_long_ago'));
}
}
}

View File

@ -59,8 +59,6 @@ use Illuminate\Support\Collection;
*/
trait PeriodOverview
{
/**
* This method returns "period entries", so nov-2015, dec-2015, etc etc (this depends on the users session range)
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for

View File

@ -1266,6 +1266,8 @@ return [
'created_Deposits' => 'Created deposits',
'created_Transfers' => 'Created transfers',
'created_from_recurrence' => 'Created from recurring transaction ":title" (#:id)',
'recurring_never_cron' => 'It seems the cron job that is necessary to support recurring transactions has never run. This is of course normal when you have just installed Firefly III, but this should be something to set up as soon as possible. Please check out the help-pages using the (?)-icon in the top right corner of the page.',
'recurring_cron_long_ago' => 'It looks like it has been more than 36 hours since the cron job to support recurring transactions has fired for the last time. Are you sure it has been set up correctly? Please check out the help-pages using the (?)-icon in the top right corner of the page.',
'recurring_meta_field_tags' => 'Tags',
'recurring_meta_field_notes' => 'Notes',