Commit 691d0e4e authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Alteration des requete pour réduire le nombre de jointure de doctrine

parent 189967b6
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -44,8 +44,7 @@ $modules = [
    'EntretienProfessionnel',
    'Metier',
    'Application',
//    'Document',
//    'ZendDeveloperTools',
    'ZendDeveloperTools',

];

+0 −1
Original line number Diff line number Diff line
@@ -132,7 +132,6 @@ class StructureController extends AbstractActionController {
            'last' => $last,
            'campagnes' => $campagnes,
            'entretiens' => $entretiens,

        ]);
    }

+5 −0
Original line number Diff line number Diff line
@@ -50,5 +50,10 @@
        <one-to-many target-entity="Application\Entity\Db\Structure" mapped-by="parent" field="enfants"/>

        <field name="histo"     type="datetime"                 column="histo"/>

        <field name="importationCreation"           type="datetime"                 column="created_on"/>
        <field name="importationModification"       type="datetime"                 column="updated_on"/>
        <field name="importationHistorisation"      type="datetime"                 column="deleted_on"/>

    </entity>
</doctrine-mapping>
+19 −14
Original line number Diff line number Diff line
@@ -285,25 +285,32 @@ class AgentService {
        $today = $this->getDateTime();

        $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent')
            ->addSelect('statut')->join('agent.statuts', 'statut')
            ->addSelect('grade')->join('agent.grades', 'grade')
            //AFFECTATION
            ->addSelect('affectation')->join('agent.affectations', 'affectation')
            ->addSelect('structure')->join('grade.structure', 'structure')
            ->addSelect('ggrade')->join('grade.grade', 'ggrade')
            ->addSelect('astructure')->join('affectation.structure', 'astructure')
            ->andWhere('affectation.dateFin >= :today OR affectation.dateFin IS NULL')
            ->andWhere('affectation.dateDebut <= :today')
            ->andWhere('affectation.principale = :true')
            //STATUS
            ->addSelect('statut')->join('agent.statuts', 'statut')
            ->andWhere('statut.fin >= :today OR statut.fin IS NULL')
            ->andWhere('statut.debut <= :today')
            ->andWhere('statut.dispo = :false')
//            ->andWhere('statut.administratif = :true')
            ->andWhere('statut.enseignant = :false AND statut.chercheur = :false AND statut.etudiant = :false AND statut.retraite = :false')
//            ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL')
            ->andWhere('affectation.dateFin >= :today OR affectation.dateFin IS NULL')
            ->andWhere('affectation.principale = :true')
            //GRADE
            ->addSelect('grade')->join('agent.grades', 'grade')
            ->addSelect('gstructure')->join('grade.structure', 'gstructure')
            ->addSelect('ggrade')->join('grade.grade', 'ggrade')
            ->addSelect('gcorrespondance')->leftjoin('grade.bap', 'gcorrespondance')
            ->addSelect('gcorps')->leftjoin('grade.corps', 'gcorps')
            ->andWhere('grade.dateFin >= :today OR grade.dateFin IS NULL')
            ->andWhere('grade.dateDebut <= :today')
            //FICHE DE POSTE
            ->addSelect('ficheposte')->leftJoin('agent.fiches', 'ficheposte')

            ->setParameter('today', $today)
            ->setParameter('true', 'O')
            ->setParameter('false', 'N')
            ->orderBy('agent.nomUsuel, agent.prenom', 'ASC')

            ->addSelect('ficheposte')->leftJoin('agent.fiches', 'ficheposte')
            ->addSelect('poste')->leftJoin('ficheposte.poste', 'poste')
            ->andWhere('agent.delete IS NULL')
        ;

@@ -341,7 +348,6 @@ class AgentService {

    /** AgentFormation ************************************************************************************************/


    /**
     * @param Agent $agent
     * @param string $annee
@@ -349,7 +355,6 @@ class AgentService {
     */
    public function getFormationsSuiviesByAnnee(Agent $agent, string $annee)
    {

        $result = [];
        $formations = $agent->getFormationListe();
        foreach ($formations as $formation) {
+2 −0
Original line number Diff line number Diff line
@@ -291,6 +291,8 @@ class FichePosteService {
            ->addSelect('grade')->join('agent.grades', 'grade')
            ->addSelect('structure')->join('grade.structure', 'structure')
            ->addSelect('fichemetier')->leftJoin('fiche.fichesMetiers', 'fichemetier')
            ->addSelect('fichemetiertype')->leftJoin('fichemetier.ficheType', 'fichemetiertype')
            ->addSelect('metier')->leftJoin('fichemetiertype.metier', 'metier')
            ->addSelect('affectation')->join('agent.affectations', 'affectation')
            ->andWhere('statut.fin >= :today OR statut.fin IS NULL')
            ->andWhere('statut.dispo = :false')
Loading