From 1fbbaaad4da96edc884a95a1237214ad508df52b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 13 Oct 2021 14:44:10 +1100 Subject: [PATCH] Minor N+1 fixes --- app/Http/Middleware/QueryLogging.php | 8 ++++---- app/Jobs/Entity/CreateEntityPdf.php | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 4b08ad38ca44..0f126f7a45aa 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -36,9 +36,9 @@ class QueryLogging { // Enable query logging for development - if (!Ninja::isHosted() || !config('beacon.enabled')) { - return $next($request); - } + // if (!Ninja::isHosted() || !config('beacon.enabled')) { + // return $next($request); + // } $timeStart = microtime(true); DB::enableQueryLog(); @@ -52,7 +52,7 @@ class QueryLogging $timeEnd = microtime(true); $time = $timeEnd - $timeStart; - // info("Query count = {$count}"); + info("Query count = {$count}"); if($count > 175){ nlog("Query count = {$count}"); diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index bb7a511aa19c..f545db11aadb 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -93,7 +93,8 @@ class CreateEntityPdf implements ShouldQueue $this->contact = $invitation->contact; $this->client = $invitation->contact->client; - + $this->client->load('company'); + $this->disk = Ninja::isHosted() ? config('filesystems.default') : $disk; } @@ -107,7 +108,7 @@ class CreateEntityPdf implements ShouldQueue /* Init a new copy of the translator*/ $t = app('translator'); /* Set the locale*/ - App::setLocale($this->contact->preferredLocale()); + App::setLocale($this->client->locale()); /* Set customized translations _NOW_ */ $t->replace(Ninja::transformTranslations($this->client->getMergedSettings()));