protected function countShortenedUrls($url, Operation $operation, Location $location = null)
    {
        if($operation->getActivity()->getCampaign()->getInterval()){
            $isParentCampaign = false;
            $campaign = $operation->getActivity()->getCampaign();
        } elseif(
            $operation->getActivity()->getCampaign()->getParent() &&
            $operation->getActivity()->getCampaign()->getParent()->getInterval()
        ){
            $isParentCampaign = true;
            $campaign = $operation->getActivity()->getCampaign()->getParent();
        }

        $qb = $this->em
            ->getRepository('CampaignChainCoreBundle:CTA')
            ->createQueryBuilder('cta')
            ->from('CampaignChainCoreBundle:Campaign', 'c')
            ->from('CampaignChainCoreBundle:Activity', 'a')
            ->from('CampaignChainCoreBundle:Operation', 'o')
            ->where('cta.originalUrl = :originalUrl')
            ->setParameter('originalUrl', $url)
            ->andWhere('a.location = :location')
            ->setParameter('location', $operation->getActivity()->getLocation())
            ->andWhere('cta.operation = o.id')
            ->andWhere('o.activity = a.id');
        if(!$isParentCampaign) {
            $qb->andWhere('a.campaign = :campaign');
        } else {
            $qb->andWhere('a.campaign = c.id')
                ->andWhere('c.parent = :campaign');
        }
        $qb->setParameter('campaign', $campaign);

        if($location) {
            $qb->andWhere('cta.location = :location')
                ->setParameter('location', $location);
        } else {
            $qb->andWhere('cta.location IS NULL');
        }

        $results = $qb->getQuery()->getResult();

        return count($results);
    }