Code Duplication    Length = 21-26 lines in 2 locations

src/Oro/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/Oro/Bundle/SalesBundle/Entity/Repository/OpportunityRepository.php 1 location

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