mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-17 00:19:31 +00:00
Only add the joins to the parts table filter query if they are really required
This should improve the performance of the queries slightly
This commit is contained in:
parent
b176cb1ae1
commit
fbd095ab50
3 changed files with 57 additions and 22 deletions
|
|
@ -115,31 +115,31 @@ class PartFilter implements FilterInterface
|
|||
*/
|
||||
//We have to use Having here, as we use an alias column which is not supported on the where clause and would result in an error
|
||||
$this->amountSum = (new IntConstraint('amountSum'))->useHaving();
|
||||
$this->lotCount = new IntConstraint('COUNT(partLots)');
|
||||
$this->lotCount = new IntConstraint('COUNT(_partLots)');
|
||||
$this->lessThanDesired = new LessThanDesiredConstraint();
|
||||
|
||||
$this->storelocation = new EntityConstraint($nodesListBuilder, StorageLocation::class, 'partLots.storage_location');
|
||||
$this->lotNeedsRefill = new BooleanConstraint('partLots.needs_refill');
|
||||
$this->lotUnknownAmount = new BooleanConstraint('partLots.instock_unknown');
|
||||
$this->lotExpirationDate = new DateTimeConstraint('partLots.expiration_date');
|
||||
$this->lotDescription = new TextConstraint('partLots.description');
|
||||
$this->lotOwner = new EntityConstraint($nodesListBuilder, User::class, 'partLots.owner');
|
||||
$this->storelocation = new EntityConstraint($nodesListBuilder, StorageLocation::class, '_partLots.storage_location');
|
||||
$this->lotNeedsRefill = new BooleanConstraint('_partLots.needs_refill');
|
||||
$this->lotUnknownAmount = new BooleanConstraint('_partLots.instock_unknown');
|
||||
$this->lotExpirationDate = new DateTimeConstraint('_partLots.expiration_date');
|
||||
$this->lotDescription = new TextConstraint('_partLots.description');
|
||||
$this->lotOwner = new EntityConstraint($nodesListBuilder, User::class, '_partLots.owner');
|
||||
|
||||
$this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer');
|
||||
$this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number');
|
||||
$this->manufacturer_product_url = new TextConstraint('part.manufacturer_product_url');
|
||||
$this->manufacturing_status = new ChoiceConstraint('part.manufacturing_status');
|
||||
|
||||
$this->attachmentsCount = new IntConstraint('COUNT(attachments)');
|
||||
$this->attachmentType = new EntityConstraint($nodesListBuilder, AttachmentType::class, 'attachments.attachment_type');
|
||||
$this->attachmentName = new TextConstraint('attachments.name');
|
||||
$this->attachmentsCount = new IntConstraint('COUNT(_attachments)');
|
||||
$this->attachmentType = new EntityConstraint($nodesListBuilder, AttachmentType::class, '_attachments.attachment_type');
|
||||
$this->attachmentName = new TextConstraint('_attachments.name');
|
||||
|
||||
$this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier');
|
||||
$this->orderdetailsCount = new IntConstraint('COUNT(orderdetails)');
|
||||
$this->obsolete = new BooleanConstraint('orderdetails.obsolete');
|
||||
$this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, '_orderdetails.supplier');
|
||||
$this->orderdetailsCount = new IntConstraint('COUNT(_orderdetails)');
|
||||
$this->obsolete = new BooleanConstraint('_orderdetails.obsolete');
|
||||
|
||||
$this->parameters = new ArrayCollection();
|
||||
$this->parametersCount = new IntConstraint('COUNT(parameters)');
|
||||
$this->parametersCount = new IntConstraint('COUNT(_parameters)');
|
||||
}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class PartSearchFilter implements FilterInterface
|
|||
$fields_to_search[] = 'part.name';
|
||||
}
|
||||
if($this->category) {
|
||||
$fields_to_search[] = 'category.name';
|
||||
$fields_to_search[] = '_category.name';
|
||||
}
|
||||
if($this->description) {
|
||||
$fields_to_search[] = 'part.description';
|
||||
|
|
@ -94,22 +94,22 @@ class PartSearchFilter implements FilterInterface
|
|||
$fields_to_search[] = 'part.tags';
|
||||
}
|
||||
if($this->storelocation) {
|
||||
$fields_to_search[] = 'storelocations.name';
|
||||
$fields_to_search[] = '_storelocations.name';
|
||||
}
|
||||
if($this->ordernr) {
|
||||
$fields_to_search[] = 'orderdetails.supplierpartnr';
|
||||
$fields_to_search[] = '_orderdetails.supplierpartnr';
|
||||
}
|
||||
if($this->mpn) {
|
||||
$fields_to_search[] = 'part.manufacturer_product_number';
|
||||
}
|
||||
if($this->supplier) {
|
||||
$fields_to_search[] = 'suppliers.name';
|
||||
$fields_to_search[] = '_suppliers.name';
|
||||
}
|
||||
if($this->manufacturer) {
|
||||
$fields_to_search[] = 'manufacturer.name';
|
||||
$fields_to_search[] = '_manufacturer.name';
|
||||
}
|
||||
if($this->footprint) {
|
||||
$fields_to_search[] = 'footprint.name';
|
||||
$fields_to_search[] = '_footprint.name';
|
||||
}
|
||||
if ($this->ipn) {
|
||||
$fields_to_search[] = 'part.ipn';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue