/** * Get usage of an item on for a champion, on a specified version * * @param DLCompare\LoLApiBundle\Entity\Champion $champion * @param string $version * @param integer $maxResults * @return integer */ public function getUsage(Champion $champion, $version, Item $item) { $qb = $this->createQueryBuilder('i'); $ex = $qb->expr(); return $qb->select('COUNT(i)')->leftJoin('i.participants', 'p')->leftJoin('p.champion', 'c')->leftJoin('p.game', 'g')->where($ex->like('g.version', $ex->literal($version . '%')))->andWhere($ex->eq('c.id', $champion->getId()))->andWhere($ex->eq('i.id', $item->getId()))->getQuery()->getSingleScalarResult(); }
/** * Get main champions using an item * * @param DLCompare\LoLApiBundle\Entity\Item $item * @param integer $maxResults * @return array(DLCompare\LoLApiBundle\Entity\Champion) */ public function getMainChampions(Item $item, $maxResults = 10) { $qb = $this->createQueryBuilder('c'); $ex = $qb->expr(); return $qb->addSelect('COUNT(c) AS HIDDEN usage')->leftJoin('c.participants', 'p')->leftJoin('p.items', 'i')->leftJoin('p.game', 'g')->where($ex->eq('i.id', $item->getId()))->andWhere($ex->gt('g.duration', 35 * 60))->groupBy('c.id')->orderBy('usage', 'DESC')->setMaxResults($maxResults)->getQuery()->execute(); }
/** * Counts number of wins of participants using an item AND a champion for a specified version * * @param DLCompare\LoLApiBundle\Entity\Champion $champion * @param string $version * @param DLCompare\LoLApiBundle\Entity\Item $item * @return integer */ public function countWinsByVersionByChampionByItem(Champion $champion, $version, Item $item) { $qb = $this->createQueryBuilder('p'); $ex = $qb->expr(); $result = $qb->select('COUNT(p)')->leftJoin('p.game', 'g')->leftJoin('p.items', 'i')->leftJoin('p.champion', 'c')->where($ex->like('g.version', $ex->literal($version . '%')))->andWhere($ex->eq('c.id', $champion->getId()))->andWhere($ex->eq('i.id', $item->getId()))->andWhere($ex->eq('p.winner', $ex->literal(1)))->getQuery()->getSingleScalarResult(); return $result; }