mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for eager loading
This commit is contained in:
parent
61b007e53a
commit
25d8b8b079
@ -214,10 +214,10 @@ class BaseController extends Controller
|
||||
$query->with(
|
||||
[
|
||||
'company' => function ($query) use ($updated_at, $user) {
|
||||
$query->whereNotNull('updated_at')->with('documents');
|
||||
$query->whereNotNull('updated_at')->with('documents')->with('users');
|
||||
},
|
||||
'company.clients' => function ($query) use ($updated_at, $user) {
|
||||
$query->where('clients.updated_at', '>=', $updated_at)->with('contacts.company', 'gateway_tokens', 'documents', 'group_settings');
|
||||
$query->where('clients.updated_at', '>=', $updated_at)->with('contacts.company', 'gateway_tokens', 'documents');
|
||||
|
||||
if(!$user->hasPermission('view_client'))
|
||||
$query->where('clients.user_id', $user->id)->orWhere('clients.assigned_user_id', $user->id);
|
||||
@ -253,7 +253,7 @@ class BaseController extends Controller
|
||||
$query->where('expenses.user_id', $user->id)->orWhere('expenses.assigned_user_id', $user->id);
|
||||
},
|
||||
'company.groups' => function ($query) use ($updated_at, $user) {
|
||||
$query->where('updated_at', '>=', $updated_at);
|
||||
$query->where('updated_at', '>=', $updated_at)->with('documents');
|
||||
|
||||
if(!$user->isAdmin())
|
||||
$query->where('group_settings.user_id', $user->id);
|
||||
@ -301,7 +301,7 @@ class BaseController extends Controller
|
||||
|
||||
},
|
||||
'company.recurring_invoices'=> function ($query) use ($updated_at, $user) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents');
|
||||
$query->where('updated_at', '>=', $updated_at)->with('invitations', 'documents', 'client.gateway_tokens', 'client.group_settings');
|
||||
|
||||
if(!$user->hasPermission('view_recurring_invoice'))
|
||||
$query->where('recurring_invoices.user_id', $user->id)->orWhere('recurring_invoices.assigned_user_id', $user->id);
|
||||
@ -391,7 +391,7 @@ class BaseController extends Controller
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
},
|
||||
'company.groups' => function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
$query->where('created_at', '>=', $created_at)->with('documents');
|
||||
|
||||
},
|
||||
'company.payment_terms'=> function ($query) use ($created_at, $user) {
|
||||
@ -458,7 +458,7 @@ class BaseController extends Controller
|
||||
$query->whereNotNull('created_at')->with('documents');
|
||||
},
|
||||
'company.clients' => function ($query) use ($created_at, $user) {
|
||||
$query->where('clients.created_at', '>=', $created_at)->with('contacts.company', 'gateway_tokens', 'documents', 'group_settings');
|
||||
$query->where('clients.created_at', '>=', $created_at)->with('contacts.company', 'gateway_tokens', 'documents');
|
||||
|
||||
if(!$user->hasPermission('view_client'))
|
||||
$query->where('clients.user_id', $user->id)->orWhere('clients.assigned_user_id', $user->id);
|
||||
@ -478,12 +478,6 @@ class BaseController extends Controller
|
||||
$query->where('credits.user_id', $user->id)->orWhere('credits.assigned_user_id', $user->id);
|
||||
|
||||
},
|
||||
// 'company.designs'=> function ($query) use ($created_at, $user) {
|
||||
// $query->where('created_at', '>=', $created_at)->with('company');
|
||||
|
||||
// if(!$user->isAdmin())
|
||||
// $query->where('designs.user_id', $user->id);
|
||||
// },
|
||||
'company.documents'=> function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
},
|
||||
@ -494,7 +488,7 @@ class BaseController extends Controller
|
||||
$query->where('expenses.user_id', $user->id)->orWhere('expenses.assigned_user_id', $user->id);
|
||||
},
|
||||
'company.groups' => function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
$query->where('created_at', '>=', $created_at)->with('documents');
|
||||
|
||||
if(!$user->isAdmin())
|
||||
$query->where('group_settings.user_id', $user->id);
|
||||
|
@ -51,6 +51,8 @@ class QueryLogging
|
||||
$count = count($queries);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
|
||||
nlog("Query count = {$count}");
|
||||
|
||||
if($count > 250){
|
||||
nlog("Quer count = {$count}");
|
||||
|
@ -1241,8 +1241,11 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
/* New to convert product ids from old hashes to new hashes*/
|
||||
if($class == 'App\Models\Subscription'){
|
||||
$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);
|
||||
$obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']);
|
||||
//$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);
|
||||
//$obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']);
|
||||
//
|
||||
$obj_array['recurring_product_ids'] = '';
|
||||
$obj_array['product_ids'] = '';
|
||||
}
|
||||
|
||||
$new_obj = $class::firstOrNew(
|
||||
@ -1272,6 +1275,12 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
foreach($id_array as $id) {
|
||||
|
||||
if(!$id)
|
||||
continue;
|
||||
|
||||
$id = $this->decodePrimaryKey($id);
|
||||
|
||||
nlog($id);
|
||||
$tmp_arr[] = $this->encodePrimaryKey($this->transformId('products', $id));
|
||||
}
|
||||
|
||||
|
@ -1396,7 +1396,7 @@ class Import implements ShouldQueue
|
||||
$modified['fees_and_limits'] = $this->cleanFeesAndLimits($modified['fees_and_limits']);
|
||||
}
|
||||
|
||||
/* On Hosted platform we need to advise Stripe users to connect with Stripe Connect */
|
||||
// /* On Hosted platform we need to advise Stripe users to connect with Stripe Connect */
|
||||
if(Ninja::isHosted() && $modified['gateway_key'] == 'd14dd26a37cecc30fdd65700bfb55b23'){
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
@ -1412,6 +1412,13 @@ class Import implements ShouldQueue
|
||||
//$modified['fees_and_limits'] = [];
|
||||
|
||||
}
|
||||
|
||||
if(Ninja::isSelfHost() && $modified['gateway_key'] == 'd14dd26a47cecc30fdd65700bfb67b34'){
|
||||
|
||||
$modified['gateway_key'] = 'd14dd26a37cecc30fdd65700bfb55b23';
|
||||
|
||||
}
|
||||
|
||||
|
||||
$company_gateway = CompanyGateway::create($modified);
|
||||
|
||||
|
@ -39,8 +39,6 @@ class ClientTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'documents',
|
||||
'gateway_tokens',
|
||||
'activities',
|
||||
'ledger',
|
||||
'system_logs',
|
||||
|
@ -29,10 +29,6 @@ class CreditTransformer extends EntityTransformer
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'invitations',
|
||||
// 'history',
|
||||
// 'client',
|
||||
'documents',
|
||||
'activities',
|
||||
];
|
||||
|
||||
|
@ -31,9 +31,7 @@ class ExpenseTransformer extends EntityTransformer
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'documents',
|
||||
];
|
||||
protected $availableIncludes = [];
|
||||
|
||||
public function includeDocuments(Expense $expense)
|
||||
{
|
||||
|
@ -23,9 +23,7 @@ class InvoiceHistoryTransformer extends EntityTransformer
|
||||
'activity',
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'activity',
|
||||
];
|
||||
protected $availableIncludes = [];
|
||||
|
||||
public function transform(Backup $backup)
|
||||
{
|
||||
|
@ -31,12 +31,9 @@ class InvoiceTransformer extends EntityTransformer
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
// 'invitations',
|
||||
// 'history',
|
||||
'payments',
|
||||
'client',
|
||||
'activities',
|
||||
// 'documents',
|
||||
];
|
||||
|
||||
public function includeInvitations(Invoice $invoice)
|
||||
|
@ -32,8 +32,6 @@ class PaymentTransformer extends EntityTransformer
|
||||
protected $availableIncludes = [
|
||||
'client',
|
||||
'invoices',
|
||||
'paymentables',
|
||||
'documents',
|
||||
];
|
||||
|
||||
public function __construct($serializer = null)
|
||||
|
@ -32,7 +32,6 @@ class ProductTransformer extends EntityTransformer
|
||||
protected $availableIncludes = [
|
||||
'company',
|
||||
'user',
|
||||
'documents',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,6 @@ class ProjectTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'documents'
|
||||
];
|
||||
|
||||
public function includeDocuments(Project $project)
|
||||
|
@ -29,12 +29,7 @@ class QuoteTransformer extends EntityTransformer
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'invitations',
|
||||
'documents',
|
||||
// 'history',
|
||||
'activities',
|
||||
// 'payments',
|
||||
// 'client',
|
||||
];
|
||||
|
||||
public function includeActivities(Quote $quote)
|
||||
|
@ -31,11 +31,7 @@ class RecurringInvoiceTransformer extends EntityTransformer
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'invitations',
|
||||
'documents',
|
||||
'activities',
|
||||
// 'history',
|
||||
// 'client',
|
||||
];
|
||||
|
||||
/*
|
||||
|
@ -30,7 +30,6 @@ class TaskTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'documents'
|
||||
];
|
||||
|
||||
public function includeDocuments(Task $task)
|
||||
|
@ -35,7 +35,6 @@ class VendorTransformer extends EntityTransformer
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'activities',
|
||||
'documents',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -84,6 +84,7 @@
|
||||
"php": "^7.3|^7.4|^8.0",
|
||||
"anahkiasen/former": "^4.2",
|
||||
"barryvdh/laravel-debugbar": "^3.4",
|
||||
"beyondcode/laravel-query-detector": "^1.5",
|
||||
"brianium/paratest": "^6.1",
|
||||
"darkaonline/l5-swagger": "^8.0",
|
||||
"facade/ignition": "^2.3.6",
|
||||
@ -145,4 +146,4 @@
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
}
|
||||
|
62
composer.lock
generated
62
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c78080d7228931d63406b506f04a792f",
|
||||
"content-hash": "5bd3a1c05429cbdf59e68e211c0360c7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm/php-ansible",
|
||||
@ -11624,6 +11624,66 @@
|
||||
],
|
||||
"time": "2021-06-14T14:29:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "beyondcode/laravel-query-detector",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/beyondcode/laravel-query-detector.git",
|
||||
"reference": "4a3a0cfb5d5ddc5da59d530ef5c13e260adc6d07"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/beyondcode/laravel-query-detector/zipball/4a3a0cfb5d5ddc5da59d530ef5c13e260adc6d07",
|
||||
"reference": "4a3a0cfb5d5ddc5da59d530ef5c13e260adc6d07",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0",
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/legacy-factories": "^1.0",
|
||||
"orchestra/testbench": "^3.0 || ^4.0 || ^5.0 || ^6.0",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"BeyondCode\\QueryDetector\\QueryDetectorServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"BeyondCode\\QueryDetector\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marcel Pociot",
|
||||
"email": "marcel@beyondco.de",
|
||||
"homepage": "https://beyondcode.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Laravel N+1 Query Detector",
|
||||
"homepage": "https://github.com/beyondcode/laravel-query-detector",
|
||||
"keywords": [
|
||||
"beyondcode",
|
||||
"laravel-query-detector"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/beyondcode/laravel-query-detector/issues",
|
||||
"source": "https://github.com/beyondcode/laravel-query-detector/tree/1.5.0"
|
||||
},
|
||||
"time": "2021-02-16T22:51:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "brianium/paratest",
|
||||
"version": "v6.3.1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user