Skip to content

Commit

Permalink
Mostra monitoramento do Cocar na tela inicial
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosan committed Dec 4, 2015
1 parent 707efdd commit c94cf06
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Entity/ComputadorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,46 @@
*/
class ComputadorRepository extends EntityRepository
{
/**
* Máquinas que não estão no Cacic
*
* @return mixed
*/
public function cacicNull() {
$start = isset($start) ? $start : (time() - ((60*60*24)*30));
$start = new \DateTime(date("Y-m-d", $start));
$end = isset($end) ? $end : time();
$end = new \DateTime(date("Y-m-d", $end));

$qb = $this->createQueryBuilder('c')
->select("count(DISTINCT c.id)")
->innerJoin("CocarBundle:PingComputador", "p")
->andWhere("c.cacic_id is null")
->andWhere("p.date BETWEEN :start AND :end")
->setParameter("start", $start)
->setParameter("end", $end);

return $qb->getQuery()->getSingleScalarResult();
}

/**
* Total de computadores que pingaram nos últimos 30 dias
*
* @return mixed
*/
public function totalComp() {
$start = isset($start) ? $start : (time() - ((60*60*24)*30));
$start = new \DateTime(date("Y-m-d", $start));
$end = isset($end) ? $end : time();
$end = new \DateTime(date("Y-m-d", $end));

$qb = $this->createQueryBuilder('c')
->select("count(DISTINCT c.id)")
->innerJoin("CocarBundle:PingComputador", "p")
->andWhere("p.date BETWEEN :start AND :end")
->setParameter("start", $start)
->setParameter("end", $end);

return $qb->getQuery()->getSingleScalarResult();
}
}

0 comments on commit c94cf06

Please sign in to comment.