Пример #1
0
 /**
  * Fetch
  * 
  * @return DocumentCollection A collection of the documents returned by the query
  */
 public function fetch()
 {
     $pluckIds = function ($item) {
         return $item['id'];
     };
     $results = $this->queryBuilder->execute()->fetchAll();
     $ids = array_map($pluckIds, $results);
     return new DocumentCollection($ids, $this->librarian);
 }
Пример #2
0
 /**
  * Get list of forms ordered by it's count
  *
  * @param QueryBuilder $query
  * @param integer $limit
  * @param integer $offset
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getMostSubmitted($query, $limit = 10, $offset = 0, $column = 'fs.id', $as = 'submissions')
 {
     $asSelect = $as ? ' as ' . $as : '';
     $query->select('f.name as title, f.id, count(distinct ' . $column . ')' . $asSelect)->groupBy('f.id, f.name')->orderBy($as, 'DESC')->setMaxResults($limit)->setFirstResult($offset);
     $results = $query->execute()->fetchAll();
     return $results;
 }
Пример #3
0
 /**
  * Get pie graph data for Sent, Read and Failed email count
  *
  * @param QueryBuilder $query
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getMostEmails($query, $limit = 10, $offset = 0)
 {
     $query->setMaxResults($limit)->setFirstResult($offset);
     $results = $query->execute()->fetchAll();
     return $results;
 }
 /**
  * Count a value in a column
  *
  * @param QueryBuilder $query
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function countValue($query, $column, $value)
 {
     $query->select('count(' . $column . ') as quantity')->from(MAUTIC_TABLE_PREFIX . 'leads', 'l')->leftJoin('l', MAUTIC_TABLE_PREFIX . 'lead_points_change_log', 'lp', 'lp.lead_id = l.id')->andwhere($query->expr()->eq($column, ':value'))->setParameter('value', $value);
     $result = $query->execute()->fetch();
     return $result['quantity'];
 }
Пример #5
0
 /**
  * Get pie graph data for http statuses
  *
  * @param QueryBuilder $query
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getHttpStatuses($query)
 {
     $query->select('ad.code as status, count(ad.code) as count')->groupBy('ad.code')->orderBy('count', 'DESC');
     $results = $query->execute()->fetchAll();
     $colors = GraphHelper::$colors;
     $graphData = array();
     $i = 0;
     foreach ($results as $result) {
         if (!isset($colors[$i])) {
             $i = 0;
         }
         $color = $colors[$i];
         $graphData[] = array('label' => $result['status'], 'color' => $colors[$i]['color'], 'highlight' => $colors[$i]['highlight'], 'value' => (int) $result['count']);
         $i++;
     }
     return $graphData;
 }
Пример #6
0
 /**
  * Get pie graph data for http statuses
  *
  * @param QueryBuilder $query
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getHttpStatuses($query)
 {
     $query->select('ad.code as status, count(ad.code) as count')->groupBy('ad.code')->orderBy('count', 'DESC');
     $results = $query->execute()->fetchAll();
     $chart = new PieChart();
     foreach ($results as $result) {
         $chart->setDataset($result['status'], $result['count']);
     }
     return $chart->render();
 }