Code Duplication    Length = 21-24 lines in 2 locations

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

@@ 166-189 (lines=24) @@
163
     *
164
     * @return QueryBuilder
165
     */
166
    protected function createLeadsCountQb(\DateTime $start = null, \DateTime $end = null, $owners = [])
167
    {
168
        $qb = $this->createQueryBuilder('l');
169
170
        $qb
171
            ->select('COUNT(DISTINCT l.id)')
172
            ->innerJoin('l.opportunities', 'o');
173
        if ($start) {
174
            $qb
175
                ->andWhere('l.createdAt > :start')
176
                ->setParameter('start', $start);
177
        }
178
        if ($end) {
179
            $qb
180
                ->andWhere('l.createdAt < :end')
181
                ->setParameter('end', $end);
182
        }
183
184
        if ($owners) {
185
            QueryUtils::applyOptimizedIn($qb, 'l.owner', $owners);
186
        }
187
188
        return $qb;
189
    }
190
}
191

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

@@ 392-412 (lines=21) @@
389
     *
390
     * @return QueryBuilder
391
     */
392
    public function createOpportunitiesCountQb(DateTime $start = null, DateTime $end = null, $owners = [])
393
    {
394
        $qb = $this->createQueryBuilder('o');
395
        $qb->select('COUNT(o.id)');
396
        if ($start) {
397
            $qb
398
                ->andWhere('o.createdAt > :start')
399
                ->setParameter('start', $start);
400
        }
401
        if ($end) {
402
            $qb
403
                ->andWhere('o.createdAt < :end')
404
                ->setParameter('end', $end);
405
        }
406
407
        if ($owners) {
408
            QueryUtils::applyOptimizedIn($qb, 'o.owner', $owners);
409
        }
410
411
        return $qb;
412
    }
413
414
    /**
415
     * @param AclHelper $aclHelper