fix: improve some database queries

This commit is contained in:
Björn Fromme
2025-03-19 09:13:02 +01:00
parent 374e01cf1d
commit 9aaf996e07
6 changed files with 34 additions and 12 deletions
@@ -3,7 +3,6 @@
namespace App\Controller\Administrative\Document;
use App\Entity\Upload;
use App\Model\DocumentFilterDto;
use App\Repository\UploadRepository;
use App\Service\Common\DocumentFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
@@ -72,4 +71,4 @@ class IndexController extends AbstractController
'status' => $status,
]);
}
}
}
+4 -2
View File
@@ -31,11 +31,12 @@ class ApplicationRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('application');
$qb
->select('application', 'assignment', 'destination', 'job_profile', 'teamer')
->select('application', 'assignment', 'job_profile', 'destination', 'teamer', 'user')
->innerJoin('application.assignment', 'assignment')
->innerJoin('assignment.destination', 'destination')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('application.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->where($qb->expr()->neq('application.status', ':status'))
->setParameter('status', Application::STATUS_REJECTED)
;
@@ -159,11 +160,12 @@ class ApplicationRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('application');
return $qb
->select('application', 'assignment', 'destination', 'job_profile', 'teamer')
->select('application', 'assignment', 'destination', 'job_profile', 'teamer', 'user')
->innerJoin('application.assignment', 'assignment')
->innerJoin('assignment.destination', 'destination')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('application.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->where($qb->expr()->neq('application.status', ':status'))
->orderBy('application.createdAt', 'DESC')
->setParameter('status', Application::STATUS_REJECTED)
+9 -3
View File
@@ -155,8 +155,9 @@ class DispositionRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('disposition');
return $qb
->select('disposition', 'assignment', 'destination')
->select('disposition', 'assignment', 'job_profile', 'destination')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('assignment.destination', 'destination')
->where($qb->expr()->andX(
$qb->expr()->orX(
@@ -182,9 +183,11 @@ class DispositionRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('disposition');
$qb
->select('disposition', 'assignment', 'destination', 'feedback', 'teamer')
->select('disposition', 'assignment', 'job_profile', 'destination', 'feedback', 'teamer', 'user')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('disposition.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->innerJoin('assignment.destination', 'destination')
->leftJoin('disposition.feedback', 'feedback')
->where($qb->expr()->andX(
@@ -292,10 +295,13 @@ class DispositionRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('disposition');
return $qb
->select('disposition', 'assignment', 'destination', 'document')
->select('disposition', 'assignment', 'job_profile', 'destination', 'document', 'teamer', 'user')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('assignment.destination', 'destination')
->leftJoin('disposition.documents', 'document')
->innerJoin('disposition.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->where($qb->expr()->andX(
$qb->expr()->lte('disposition.createdAt', ':dueDate'),
$qb->expr()->eq('disposition.status', ':status'),
+4 -2
View File
@@ -32,8 +32,9 @@ class FeedbackRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('feedback');
$qb
->select('feedback', 'teamer')
->select('feedback', 'teamer', 'user')
->innerJoin('feedback.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
;
if (null !== $name = $filterDto->getName()) {
@@ -73,8 +74,9 @@ class FeedbackRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('feedback');
return $qb
->select('feedback', 'teamer')
->select('feedback', 'teamer', 'user')
->innerJoin('feedback.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->where($qb->expr()->eq('feedback.status', ':status'))
->setParameter('status', Feedback::STATUS_NEW)
->orderBy('feedback.createdAt', 'DESC')
+6 -3
View File
@@ -87,12 +87,13 @@ class UploadRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('upload');
return $qb
->select('upload', 'disposition', 'assignment', 'job_profile', 'destination', 'teamer')
->select('upload', 'disposition', 'assignment', 'job_profile', 'destination', 'teamer', 'user')
->innerJoin('upload.disposition', 'disposition')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('assignment.destination', 'destination')
->innerJoin('disposition.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->where($qb->expr()->andX(
$qb->expr()->eq('upload.type', ':type'),
$qb->expr()->eq('upload.status', ':status'),
@@ -120,12 +121,13 @@ class UploadRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('upload');
$qb
->select('upload', 'disposition', 'assignment', 'job_profile', 'destination', 'teamer')
->select('upload', 'disposition', 'assignment', 'job_profile', 'destination', 'teamer', 'user')
->innerJoin('upload.disposition', 'disposition')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('assignment.destination', 'destination')
->innerJoin('disposition.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->addOrderBy('FIELD(upload.status, :checked, :new)', 'DESC')
->setParameter('new', Upload::STATUS_NEW)
->setParameter('checked', Upload::STATUS_CHECKED)
@@ -188,9 +190,10 @@ class UploadRepository extends ServiceEntityRepository
$qb = $this->createQueryBuilder('upload');
return $qb
->select('upload', 'owner', 'teamer', 'disposition', 'assignment')
->select('upload', 'owner', 'teamer', 'user', 'disposition', 'assignment')
->innerJoin('upload.owner', 'owner')
->innerJoin('owner.teamer', 'teamer')
->innerJoin('teamer.user', 'user')
->leftJoin('upload.disposition', 'disposition')
->leftJoin('disposition.assignment', 'assignment')
->where($qb->expr()->andX(