protected function getTotalsByInterval($entity, DateTime $from = null, DateTime $to = null)
{
$namespace = $this->container->getParameter($entity);
$queryBuilder = $this->get('elcodi.provider.manager')->getManagerByEntityNamespace($namespace)->createQueryBuilder()->select('count(x.id)')->from($namespace, 'x');
if (is_null($to)) {
$to = new DateTime();
}
if (!is_null($from)) {
$queryBuilder->andWhere('x.createdAt >= ?1')->andWhere('x.createdAt <= ?2')->setParameters([1 => $from, 2 => $to]);
}
return $queryBuilder->getQuery()->getSingleScalarResult();
}