public function build()
 {
     $data = array();
     $currentFrom = clone $this->dateRange->getFrom();
     $interval = new \DateInterval($this->interval);
     $interval1Sec = new \DateInterval("PT1S");
     while ($currentFrom < $this->dateRange->getTo()) {
         $currentTo = clone $currentFrom;
         $currentTo->add($interval);
         $currentTo->sub($interval1Sec);
         $data[] = new StatsDateRange(clone $currentFrom, $currentTo);
         $currentFrom->add($interval);
     }
     return $data;
 }
 public function getStatsCountTimesRanIncludedNode(Node $node, StatsDateRange $statsDateRange)
 {
     $data = $this->getEntityManager()->createQuery('SELECT vsrtv.id AS x FROM QuestionKeyBundle:VisitorSessionRanTreeVersion vsrtv' . ' JOIN  vsrtv.onNodes vson' . ' WHERE vson.node = :node  AND vsrtv.createdAt > :from AND vsrtv.createdAt < :to  ' . ' GROUP BY vsrtv.id  ')->setParameter('node', $node)->setParameter('from', $statsDateRange->getFrom())->setParameter('to', $statsDateRange->getTo())->getResult();
     return count($data);
 }