Commit 98516315 by Julien Jorry

Fix stats for presta / partenaire on homepage

parent 1894398b
......@@ -32,33 +32,29 @@ class StatsExtension extends AbstractExtension
public function showMlcStats($stats)
{
$class = '';
switch($stats) {
switch ($stats) {
case 'user':
$class = 'App\Entity\User';
break;
case 'prestataire':
$class = 'App\Entity\Prestataire';
$class = null;
$typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('prestataire');
$query = $this->em->createQuery(
'SELECT count(distinct p.id)
FROM '.$class.' p
WHERE p.enabled = true AND p.typeprestataire = :typepresta
')
->setParameter('typepresta', $typepresta)
;
FROM App\\Entity\\Prestataire p
WHERE p.enabled = true AND p.typeprestataire = :typepresta'
)->setParameter('typepresta', $typepresta);
$val = $query->getSingleScalarResult();
break;
case 'partenaire':
$class = 'App\Entity\Prestataire';
$class = null;
$typepresta = $this->em->getRepository(TypePrestataire::class)->findOneBySlug('partenaire');
$query = $this->em->createQuery(
'SELECT count(distinct p.id)
FROM '.$class.' p
WHERE p.enabled = true AND p.typeprestataire = :typepresta
')
->setParameter('typepresta', $typepresta)
;
FROM App\\Entity\\Prestataire p
WHERE p.enabled = true AND p.typeprestataire = :typepresta'
)->setParameter('typepresta', $typepresta);
$val = $query->getSingleScalarResult();
break;
......@@ -71,15 +67,13 @@ class StatsExtension extends AbstractExtension
case 'groupe':
$class = 'App\Entity\Groupe';
break;
}
if (!empty($class)) {
$query2 = $this->em->createQuery(
'SELECT count(distinct u.id)
FROM '.$class.' u
WHERE u.enabled = true
')
;
WHERE u.enabled = true'
);
$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