Code Duplication    Length = 17-17 lines in 2 locations

src/OroCRM/Bundle/MagentoBundle/Entity/Repository/CustomerRepository.php 1 location

@@ 74-90 (lines=17) @@
71
     * @return int
72
     * @throws \Doctrine\ORM\NonUniqueResultException
73
     */
74
    public function getReturningCustomersWhoMadeOrderByPeriod(\DateTime $start, \DateTime $end, AclHelper $aclHelper)
75
    {
76
        $qb = $this->_em->createQueryBuilder();
77
        $qb->select('COUNT(customer.id) as val')
78
            ->from('OroCRMMagentoBundle:Order', 'orders')
79
            ->join('orders.customer', 'customer')
80
            ->having('COUNT(orders.id) > 0')
81
            ->andWhere('customer.createdAt < :dateStart')
82
            ->andWhere($qb->expr()->between('orders.createdAt', ':dateStart', ':dateEnd'))
83
            ->setParameter('dateStart', $start)
84
            ->setParameter('dateEnd', $end);
85
        $this->applyActiveChannelLimitation($qb);
86
87
        $value = $aclHelper->apply($qb)->getOneOrNullResult();
88
89
        return $value['val'] ?  : 0;
90
    }
91
92
    /**
93
     * Returns data grouped by created_at, data_channel_id

src/OroCRM/Bundle/SalesBundle/Entity/Repository/LeadRepository.php 1 location

@@ 22-38 (lines=17) @@
19
     * @param  array     $dateRange
20
     * @return array     [itemCount, label]
21
     */
22
    public function getOpportunitiesByLeadSource(AclHelper $aclHelper, $limit = 10, $dateRange = null)
23
    {
24
        $qb   = $this->createQueryBuilder('l')
25
            ->select('s.id as source, count(o.id) as itemCount')
26
            ->leftJoin('l.opportunities', 'o')
27
            ->leftJoin('l.source', 's')
28
            ->groupBy('source');
29
30
        if ($dateRange) {
31
            $qb->andWhere($qb->expr()->between('o.createdAt', ':dateStart', ':dateEnd'))
32
                ->setParameter('dateStart', $dateRange['start'])
33
                ->setParameter('dateEnd', $dateRange['end']);
34
        }
35
        $rows = $aclHelper->apply($qb)->getArrayResult();
36
37
        return $this->processOpportunitiesByLeadSource($rows, $limit);
38
    }
39
40
    /**
41
     * @param array $rows