Newscoop\Services\CommentService::getCommentCounts PHP Method

getCommentCounts() public method

Get articles comment counts
public getCommentCounts ( array $ids, $recommended = false, $all = false ) : array
$ids array
return array
    public function getCommentCounts(array $ids, $recommended = false, $all = false)
    {
        $qb = $this->getRepository()->createQueryBuilder('c')->select('COUNT(c), c.thread')->andWhere('c.thread IN (:ids)')->andWhere('c.status = :status');
        if (!$all) {
            if ($recommended) {
                $qb->andWhere('c.recommended = 1');
            } else {
                $qb->andWhere('c.recommended <> 1');
            }
        }
        return $qb->groupBy('c.thread')->setParameter('ids', array_values($ids))->setParameter('status', Comment::STATUS_APPROVED)->getQuery()->getResult();
    }