Commit d9059f70905f76e343092f014f8dd849ebab7bb5
Committed by
Eduardo Santos
1 parent
88edaeaf
Exists in
master
and in
1 other branch
Melhoria de performance em todas as páginas alterando a consulta do Menu
Showing
3 changed files
with
18 additions
and
6 deletions
Show diff stats
src/Cacic/CommonBundle/Entity/ComputadorColetaRepository.php
| ... | ... | @@ -99,13 +99,16 @@ class ComputadorColetaRepository extends EntityRepository |
| 99 | 99 | public function menu() |
| 100 | 100 | { |
| 101 | 101 | $_dql = "SELECT c |
| 102 | - FROM CacicCommonBundle:ComputadorColeta coleta | |
| 103 | - INNER JOIN CacicCommonBundle:ClassProperty property WITH coleta.classProperty = property.idClassProperty | |
| 104 | - INNER JOIN CacicCommonBundle:Classe c WITH property.idClass = c.idClass | |
| 102 | + FROM CacicCommonBundle:Classe c | |
| 105 | 103 | WHERE c.nmClassName NOT IN ('SoftwareList', 'Patrimonio') |
| 106 | 104 | ORDER BY c.nmClassName"; |
| 107 | 105 | |
| 108 | - return $this->getEntityManager()->createQuery( $_dql )->getArrayResult(); | |
| 106 | + $_dql = $this->getEntityManager()->createQuery( $_dql ); | |
| 107 | + | |
| 108 | + $_dql->useResultCache(true); | |
| 109 | + $_dql->setResultCacheLifetime(3600); | |
| 110 | + | |
| 111 | + return $_dql->getArrayResult(); | |
| 109 | 112 | } |
| 110 | 113 | |
| 111 | 114 | /** | ... | ... |
src/Cacic/CommonBundle/Entity/ComputadorRepository.php
| ... | ... | @@ -156,7 +156,12 @@ class ComputadorRepository extends EntityRepository |
| 156 | 156 | ->innerJoin('comp.idSo', 'so') |
| 157 | 157 | ->groupBy('so'); |
| 158 | 158 | |
| 159 | - return $qb->getQuery()->getResult(); | |
| 159 | + | |
| 160 | + $qb = $qb->getQuery(); | |
| 161 | + $qb->useResultCache(true); | |
| 162 | + $qb->setResultCacheLifetime(600); | |
| 163 | + | |
| 164 | + return $qb->getResult(); | |
| 160 | 165 | } |
| 161 | 166 | |
| 162 | 167 | /** | ... | ... |
src/Cacic/CommonBundle/Entity/LogAcessoRepository.php
| ... | ... | @@ -101,7 +101,11 @@ class LogAcessoRepository extends EntityRepository |
| 101 | 101 | ->innerJoin('CacicCommonBundle:Computador','comp', 'WITH', 'log.idComputador = comp.idComputador') |
| 102 | 102 | ->andWhere( 'log.data >= (current_date() - 30)' ); |
| 103 | 103 | |
| 104 | - return $query->getQuery()->execute(); | |
| 104 | + $query = $query->getQuery(); | |
| 105 | + $query->useResultCache(true); | |
| 106 | + $query->setResultCacheLifetime(600); | |
| 107 | + | |
| 108 | + return $query->execute(); | |
| 105 | 109 | } |
| 106 | 110 | public function faturamentoCsv( $dataInicio, $dataFim, $locais ) |
| 107 | 111 | { | ... | ... |