diff --git a/app/Console/Commands/ReportCache.php b/app/Console/Commands/ReportCache.php index 759d1b5a9..c11dffc0e 100644 --- a/app/Console/Commands/ReportCache.php +++ b/app/Console/Commands/ReportCache.php @@ -59,19 +59,25 @@ class ReportCache extends Command $reports = Report::orderBy('name')->get(); foreach ($reports as $report) { - $class = Utility::getClassInstance($report, false); + try { + $class = Utility::getClassInstance($report, false); - if (empty($class)) { - continue; + if (empty($class)) { + continue; + } + + $ttl = 3600 * 6; // 6 hours + + Cache::forget('reports.totals.' . $report->id); + + Cache::remember('reports.totals.' . $report->id, $ttl, function () use ($class) { + return $class->getGrandTotal(); + }); + } catch (\Throwable $e) { + $this->error($e->getMessage()); + + report($e); } - - $ttl = 3600 * 6; // 6 hours - - Cache::forget('reports.totals.' . $report->id); - - Cache::remember('reports.totals.' . $report->id, $ttl, function () use ($class) { - return $class->getGrandTotal(); - }); } } } diff --git a/app/Listeners/Update/V21/Version2117.php b/app/Listeners/Update/V21/Version2117.php index 82fe98614..20f4c2f5c 100644 --- a/app/Listeners/Update/V21/Version2117.php +++ b/app/Listeners/Update/V21/Version2117.php @@ -51,8 +51,12 @@ class Version2117 extends Listener protected function cacheReports() { - Report::all()->each(function ($report) { - Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getGrandTotal()); - }); + try { + Report::all()->each(function ($report) { + Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getGrandTotal()); + }); + } catch (\Throwable $e) { + report($e); + } } }