Commit 98516315 by Julien Jorry

Fix stats for presta / partenaire on homepage

parent 1894398b
...@@ -32,33 +32,29 @@ class StatsExtension extends AbstractExtension ...@@ -32,33 +32,29 @@ class StatsExtension extends AbstractExtension
public function showMlcStats($stats) public function showMlcStats($stats)
{ {
$class = ''; $class = '';
switch($stats) { switch ($stats) {
case 'user': case 'user':
$class = 'App\Entity\User'; $class = 'App\Entity\User';
break; break;
case 'prestataire': case 'prestataire':
$class = 'App\Entity\Prestataire'; $class = null;
$typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('prestataire'); $typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('prestataire');
$query = $this->em->createQuery( $query = $this->em->createQuery(
'SELECT count(distinct p.id) 'SELECT count(distinct p.id)
FROM '.$class.' p FROM App\\Entity\\Prestataire p
WHERE p.enabled = true AND p.typeprestataire = :typepresta WHERE p.enabled = true AND p.typeprestataire = :typepresta'
') )->setParameter('typepresta', $typepresta);
->setParameter('typepresta', $typepresta)
;
$val = $query->getSingleScalarResult(); $val = $query->getSingleScalarResult();
break; break;
case 'partenaire': case 'partenaire':
$class = 'App\Entity\Prestataire'; $class = null;
$typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('partenaire'); $typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('partenaire');
$query = $this->em->createQuery( $query = $this->em->createQuery(
'SELECT count(distinct p.id) 'SELECT count(distinct p.id)
FROM '.$class.' p FROM App\\Entity\\Prestataire p
WHERE p.enabled = true AND p.typeprestataire = :typepresta WHERE p.enabled = true AND p.typeprestataire = :typepresta'
') )->setParameter('typepresta', $typepresta);
->setParameter('typepresta', $typepresta)
;
$val = $query->getSingleScalarResult(); $val = $query->getSingleScalarResult();
break; break;
...@@ -71,15 +67,13 @@ class StatsExtension extends AbstractExtension ...@@ -71,15 +67,13 @@ class StatsExtension extends AbstractExtension
case 'groupe': case 'groupe':
$class = 'App\Entity\Groupe'; $class = 'App\Entity\Groupe';
break; break;
} }
if (!empty($class)) { if (!empty($class)) {
$query2 = $this->em->createQuery( $query2 = $this->em->createQuery(
'SELECT count(distinct u.id) 'SELECT count(distinct u.id)
FROM '.$class.' u FROM '.$class.' u
WHERE u.enabled = true WHERE u.enabled = true'
') );
;
$val = $query2->getSingleScalarResult(); $val = $query2->getSingleScalarResult();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment