mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Improvements for cache when running setup for the first time
This commit is contained in:
parent
52a982d634
commit
dcbfc6c170
@ -1 +1 @@
|
||||
5.5.55
|
||||
5.5.56
|
@ -134,6 +134,9 @@ class CreateAccount extends Command
|
||||
(new CreateCompanyPaymentTerms($company, $user))->handle();
|
||||
(new CreateCompanyTaskStatuses($company, $user))->handle();
|
||||
(new VersionCheck())->handle();
|
||||
|
||||
$this->warmCache();
|
||||
|
||||
}
|
||||
|
||||
private function warmCache()
|
||||
@ -142,25 +145,20 @@ class CreateAccount extends Command
|
||||
$cached_tables = config('ninja.cached_tables');
|
||||
|
||||
foreach ($cached_tables as $name => $class) {
|
||||
if (! Cache::has($name)) {
|
||||
// check that the table exists in case the migration is pending
|
||||
if (! Schema::hasTable((new $class())->getTable())) {
|
||||
continue;
|
||||
}
|
||||
if ($name == 'payment_terms') {
|
||||
$orderBy = 'num_days';
|
||||
} elseif ($name == 'fonts') {
|
||||
$orderBy = 'sort_order';
|
||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
||||
$orderBy = 'name';
|
||||
} else {
|
||||
$orderBy = 'id';
|
||||
}
|
||||
$tableData = $class::orderBy($orderBy)->get();
|
||||
if ($tableData->count()) {
|
||||
Cache::forever($name, $tableData);
|
||||
}
|
||||
if ($name == 'payment_terms') {
|
||||
$orderBy = 'num_days';
|
||||
} elseif ($name == 'fonts') {
|
||||
$orderBy = 'sort_order';
|
||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
||||
$orderBy = 'name';
|
||||
} else {
|
||||
$orderBy = 'id';
|
||||
}
|
||||
$tableData = $class::orderBy($orderBy)->get();
|
||||
if ($tableData->count()) {
|
||||
Cache::forever($name, $tableData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,10 @@ use App\Exceptions\InternalPDFFailure;
|
||||
use App\Exceptions\PhantomPDFFailure;
|
||||
use App\Exceptions\StripeConnectFailure;
|
||||
use App\Utils\Ninja;
|
||||
use Exception;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\RelationNotFoundException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\Exceptions\ThrottleRequestsException;
|
||||
use Illuminate\Http\Request;
|
||||
@ -34,7 +32,6 @@ use Illuminate\Validation\ValidationException;
|
||||
use PDOException;
|
||||
use Sentry\Laravel\Integration;
|
||||
use Sentry\State\Scope;
|
||||
use Swift_TransportException;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
@ -50,7 +47,6 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
protected $dontReport = [
|
||||
PDOException::class,
|
||||
//Swift_TransportException::class,
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
ValidationException::class,
|
||||
@ -80,11 +76,10 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
if (! Schema::hasTable('accounts')) {
|
||||
info('account table not found');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Ninja::isHosted() && ! ($exception instanceof ValidationException)) {
|
||||
if (Ninja::isHosted()) {
|
||||
Integration::configureScope(function (Scope $scope): void {
|
||||
$name = 'hosted@invoiceninja.com';
|
||||
|
||||
@ -105,7 +100,10 @@ class Handler extends ExceptionHandler
|
||||
]);
|
||||
});
|
||||
|
||||
Integration::captureUnhandledException($exception);
|
||||
if ($this->validException($exception)) {
|
||||
Integration::captureUnhandledException($exception);
|
||||
}
|
||||
|
||||
} elseif (app()->bound('sentry') && $this->shouldReport($exception)) {
|
||||
Integration::configureScope(function (Scope $scope): void {
|
||||
if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) {
|
||||
@ -180,8 +178,8 @@ class Handler extends ExceptionHandler
|
||||
return response()->json(['message' => $exception->getMessage()], 500);
|
||||
} elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
|
||||
return response()->json(['message'=>'Too many requests'], 429);
|
||||
} elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
|
||||
return response()->json(['message'=>'Fatal error'], 500);
|
||||
// } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
|
||||
// return response()->json(['message'=>'Fatal error'], 500); //@deprecated
|
||||
} elseif ($exception instanceof AuthorizationException) {
|
||||
return response()->json(['message'=> $exception->getMessage()], 401);
|
||||
} elseif ($exception instanceof TokenMismatchException) {
|
||||
@ -208,13 +206,6 @@ class Handler extends ExceptionHandler
|
||||
return response()->json(['message' => $exception->getMessage()], 400);
|
||||
}
|
||||
|
||||
|
||||
// elseif ($exception instanceof QueryException) {
|
||||
// return response()->json(['message' => 'We had a problem executing this query. Please retry.'], 500);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => '5.5.55',
|
||||
'app_tag' => '5.5.55',
|
||||
'app_version' => '5.5.56',
|
||||
'app_tag' => '5.5.56',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user