mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fetch the manyTo* entity collections of parts with other part columns
This reduces the query count and should improve performance especially for big tables.
This commit is contained in:
parent
01b790a8d0
commit
988c53bead
2 changed files with 89 additions and 1 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\DataTables\Adapter\CustomORMAdapter;
|
||||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\DataTables\Column\MarkdownColumn;
|
||||
|
@ -84,14 +85,20 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
->addSelect('partUnit')
|
||||
->addSelect('master_picture_attachment')
|
||||
->addSelect('footprint_attachment')
|
||||
->addSelect('partLots')
|
||||
->addSelect('orderdetails')
|
||||
->addSelect('attachments')
|
||||
->addSelect('storelocations')
|
||||
->from(Part::class, 'part')
|
||||
->leftJoin('part.category', 'category')
|
||||
->leftJoin('part.master_picture_attachment', 'master_picture_attachment')
|
||||
->leftJoin('part.partLots', 'partLots')
|
||||
->leftJoin('partLots.storage_location', 'storelocations')
|
||||
->leftJoin('part.footprint', 'footprint')
|
||||
->leftJoin('footprint.master_picture_attachment', 'footprint_attachment')
|
||||
->leftJoin('part.manufacturer', 'manufacturer')
|
||||
->leftJoin('part.orderdetails', 'orderdetails')
|
||||
->leftJoin('part.attachments', 'attachments')
|
||||
->leftJoin('part.partUnit', 'partUnit');
|
||||
}
|
||||
|
||||
|
@ -290,7 +297,7 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
])
|
||||
|
||||
->addOrderBy('name')
|
||||
->createAdapter(ORMAdapter::class, [
|
||||
->createAdapter(CustomORMAdapter::class, [
|
||||
'query' => function (QueryBuilder $builder) {
|
||||
$this->getQuery($builder);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue