mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Performance improvements for eager loading (#3584)
* Fixes for Sentry * performance improvements for eager loading
This commit is contained in:
parent
f99a89834b
commit
cfafd65be0
@ -60,14 +60,14 @@ class Handler extends ExceptionHandler
|
||||
|
||||
app('sentry')->configureScope(function (Scope $scope): void {
|
||||
|
||||
if(auth()->guard('contact')->user() && auth()->guard('contact')->user()->account->report_errors) {
|
||||
if(auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) {
|
||||
$scope->setUser([
|
||||
'id' => auth()->guard('contact')->user()->account->key,
|
||||
'id' => auth()->guard('contact')->user()->company->account->key,
|
||||
'email' => "anonymous@example.com",
|
||||
'name' => "Anonymous User",
|
||||
]);
|
||||
}
|
||||
else if (auth()->user() && auth()->user()->account->report_errors) {
|
||||
}
|
||||
else if (auth()->guard('user')->user() && auth()->user()->company()->account->report_errors) {
|
||||
$scope->setUser([
|
||||
'id' => auth()->user()->account->key,
|
||||
'email' => "anonymous@example.com",
|
||||
@ -75,6 +75,7 @@ class Handler extends ExceptionHandler
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
app('sentry')->captureException($exception);
|
||||
|
@ -172,9 +172,11 @@ class LoginController extends BaseController
|
||||
|
||||
$user->setCompany($user->company_user->account->default_company);
|
||||
|
||||
$ct = CompanyUser::whereUserId($user->id)->with('company');
|
||||
// $ct = CompanyUser::whereUserId($user->id)->with('company');
|
||||
$ct = CompanyUser::whereUserId($user->id);
|
||||
|
||||
return $this->listResponse($ct);
|
||||
|
||||
} else {
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
|
@ -81,6 +81,8 @@ class BaseController extends Controller
|
||||
$include = implode(",", $this->forced_includes);
|
||||
}
|
||||
|
||||
\Log::error(print_r($include,1));
|
||||
|
||||
$this->manager->parseIncludes($include);
|
||||
|
||||
$this->serializer = request()->input('serializer') ?: EntityTransformer::API_SERIALIZER_ARRAY;
|
||||
@ -256,10 +258,10 @@ class BaseController extends Controller
|
||||
'company.company_gateways.gateway',
|
||||
'company.clients.contacts',
|
||||
'company.products',
|
||||
'company.invoices',
|
||||
'company.invoices.invitations.company',
|
||||
'company.payments.paymentables',
|
||||
'company.quotes',
|
||||
'company.credits',
|
||||
'company.quotes.invitations.company',
|
||||
'company.credits.invitations.company',
|
||||
'company.vendors.contacts',
|
||||
'company.expenses',
|
||||
'company.tasks',
|
||||
|
@ -123,7 +123,7 @@ class InvoiceController extends Controller
|
||||
|
||||
$invoices->map(function ($invoice) {
|
||||
$invoice->balance = Number::formatMoney($invoice->balance, $invoice->client);
|
||||
$invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format());
|
||||
//$invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format());
|
||||
return $invoice;
|
||||
});
|
||||
|
||||
|
@ -45,6 +45,11 @@ class SetupController extends Controller
|
||||
return back(); // This should never be reached.
|
||||
}
|
||||
|
||||
$mail_driver = $request->input('mail_driver');
|
||||
|
||||
if(!$this->failsafeMailCheck())
|
||||
$mail_driver = 'log';
|
||||
|
||||
$_ENV['APP_KEY'] = config('app.key');
|
||||
$_ENV['APP_URL'] = $request->input('url');
|
||||
$_ENV['APP_DEBUG'] = $request->input('debug') ? 'true' : 'false';
|
||||
@ -54,7 +59,7 @@ class SetupController extends Controller
|
||||
$_ENV['DB_DATABASE1'] = $request->input('database');
|
||||
$_ENV['DB_USERNAME1'] = $request->input('db_username');
|
||||
$_ENV['DB_PASSWORD1'] = $request->input('db_password');
|
||||
$_ENV['MAIL_DRIVER'] = $request->input('mail_driver');
|
||||
$_ENV['MAIL_DRIVER'] = $mail_driver;
|
||||
$_ENV['MAIL_PORT'] = $request->input('mail_port');
|
||||
$_ENV['MAIL_ENCRYPTION'] = $request->input('encryption');
|
||||
$_ENV['MAIL_HOST'] = $request->input('mail_host');
|
||||
@ -154,4 +159,17 @@ class SetupController extends Controller
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
}
|
||||
}
|
||||
|
||||
private function failsafeMailCheck($request)
|
||||
{
|
||||
|
||||
$response_array = SystemHealth::testMailServer($request);
|
||||
|
||||
if($response_array instanceof Response)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\ViewComposers;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Currency;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Utils\TranslationHelper;
|
||||
use Cache;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class TranslationComposer
|
||||
{
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view) :void
|
||||
{
|
||||
$view->with('industries', TranslationHelper::getIndustries());
|
||||
|
||||
$view->with('countries', TranslationHelper::getCountries());
|
||||
|
||||
$view->with('payment_types', TranslationHelper::getPaymentTypes());
|
||||
|
||||
$view->with('languages', TranslationHelper::getLanguages());
|
||||
|
||||
$view->with('currencies', TranslationHelper::getCurrencies());
|
||||
|
||||
$view->with('payment_terms', TranslationHelper::getPaymentTerms());
|
||||
}
|
||||
}
|
@ -331,13 +331,17 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
public function getCreditCardGateway() :?CompanyGateway
|
||||
{
|
||||
$company_gateways = $this->getSetting('company_gateway_ids');
|
||||
|
||||
if ($company_gateways) {
|
||||
|
||||
info($company_gateways);
|
||||
info($this->company->id);
|
||||
if (strlen($company_gateways)>=1) {
|
||||
$gateways = $this->company->company_gateways->whereIn('id', $payment_gateways);
|
||||
} else {
|
||||
$gateways = $this->company->company_gateways;
|
||||
}
|
||||
|
||||
\Log::error($gateways);
|
||||
|
||||
foreach ($gateways as $gateway) {
|
||||
if (in_array(GatewayType::CREDIT_CARD, $gateway->driver($this)->gatewayTypes())) {
|
||||
return $gateway;
|
||||
|
@ -23,16 +23,6 @@ class ComposerServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
view()->composer('portal.*', 'App\Http\ViewComposers\PortalComposer');
|
||||
|
||||
//view()->composer('*', 'App\Http\ViewComposers\HeaderComposer');
|
||||
/*
|
||||
view()->composer(
|
||||
[
|
||||
'client.edit',
|
||||
],
|
||||
'App\Http\ViewComposers\TranslationComposer'
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ trait Inviteable
|
||||
$entity_type = strtolower(class_basename($this->entityType()));
|
||||
|
||||
//$this->with('company','contact',$this->entity_type);
|
||||
$this->with('company');
|
||||
//$this->with('company');
|
||||
|
||||
$domain = isset($this->company->portal_domain) ?: $this->company->domain();
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
{{ $invoice->number }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->due_date }} <!-- $invoice->formatDate($invoice->date, $invoice->client->date_format())-->
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||
{{ App\Utils\Number::formatMoney($invoice->balance, $invoice->client) }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user