Code Duplication    Length = 21-26 lines in 2 locations

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

@@ 193-218 (lines=26) @@
190
     *
191
     * @return QueryBuilder
192
     */
193
    protected function createLeadsCountQb(
194
        \DateTime $start = null,
195
        \DateTime $end = null,
196
        $owners = []
197
    ) {
198
        $qb = $this
199
            ->createQueryBuilder('l')
200
            ->select('COUNT(DISTINCT l.id)');
201
202
        if ($start) {
203
            $qb
204
                ->andWhere('l.createdAt > :start')
205
                ->setParameter('start', $start);
206
        }
207
        if ($end) {
208
            $qb
209
                ->andWhere('l.createdAt < :end')
210
                ->setParameter('end', $end);
211
        }
212
213
        if ($owners) {
214
            QueryUtils::applyOptimizedIn($qb, 'l.owner', $owners);
215
        }
216
217
        return $qb;
218
    }
219
}
220

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

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