<commit_before><?php

namespace AppBundle\Repository;

use AppBundle\Entity\FennecUser;
use AppBundle\Service\DBVersion;
use Doctrine\ORM\EntityRepository;

/**
 * OrganismRepository
 *
 * This class was generated by the PhpStorm "Php Annotations" Plugin. Add your own custom
 * repository methods below.
 */
class OrganismRepository extends EntityRepository
{
    public function getNumber(): int {
        $query = $this->getEntityManager()->createQuery('SELECT COUNT(o.fennecId) FROM AppBundle\Entity\Organism o');
        return $query->getSingleScalarResult();
    }

    public function getListOfOrganisms($limit, $search): array {
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('organism')
            ->from('AppBundle\Entity\Organism', 'organism')
            ->where('LOWER(organism.scientificName) LIKE LOWER(:search)')
            ->setParameter('search', $search)
            ->setMaxResults($limit);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        $data = array();
        for($i=0; $i<sizeof($result);$i++){
            $thisResult = array();
            $thisResult['fennec_id'] = $result[$i]['fennecId'];
            $thisResult['scientific_name'] = $result[$i]['scientificName'];
            $data[] = $thisResult;
        }
        return $data;
    }

    public function getDetailsOfOrganism($fennec_id, $dbversion, $user){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('organism')
            ->from('AppBundle\Entity\Organism','organism')
            ->where('organism.fennecId = :id')
            ->setParameter('id', $fennec_id);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();

        $data = array();
        for($i=0; $i<sizeof($result);$i++) {
            $data['fennec_id'] = $result[$i]['fennecId'];
            $data['scientific_name'] = $result[$i]['scientificName'];
            $data['eol_identifier'] = $this->getIdentifierDbxref($result[$i]['fennecId'], 'EOL');
            $data['ncbi_identifier'] = $this->getIdentifierDbxref($result[$i]['fennecId'], 'ncbi_taxonomy');
        }
        return $result;
    }

    /**
     * @param int $fennec_id
     * @param string $db_name
     * @return string $identifier identifier of the current organism in the defined database
     */
    private function getIdentifierDbxref($fennec_id, $db_name)
    {
        $db_id = $this->getDBId($db_name);
        return $this->getIdentifier($fennec_id, $db_id);
    }

    private function getDBId($db_name){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('db.dbId')
            ->from('AppBundle\Entity\Db', 'db')
            ->where('db.name = :dbName')
            ->setParameter('dbName', $db_name);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        for($i=0; $i < sizeof($result); $i++) {
            $db_id = $result[$i]['dbId'];
        }
        if (!isset($db_id)) {
            return "";
        }
        return $db_id;
    }

    private function getIdentifier($fennec_id, $db_id){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('d.identifier')
            ->from('AppBundle\Entity\FennecDbxref','d')
            ->where('d.db = :dbId')
            ->andWhere('d.fennec = :fennecId')
            ->setParameter('dbId',$db_id)
            ->setParameter('fennecId', $fennec_id);

        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        for($i=0; $i < sizeof($result); $i++) {
            $identifier = $result[$i]['identifier'];
        }
        if (!isset($identifier)) {
            return "";
        }
        return $identifier;
    }
}
<commit_msg>Remove unused parameters<commit_after><?php

namespace AppBundle\Repository;

use AppBundle\Entity\FennecUser;
use AppBundle\Service\DBVersion;
use Doctrine\ORM\EntityRepository;

/**
 * OrganismRepository
 *
 * This class was generated by the PhpStorm "Php Annotations" Plugin. Add your own custom
 * repository methods below.
 */
class OrganismRepository extends EntityRepository
{
    public function getNumber(): int {
        $query = $this->getEntityManager()->createQuery('SELECT COUNT(o.fennecId) FROM AppBundle\Entity\Organism o');
        return $query->getSingleScalarResult();
    }

    public function getListOfOrganisms($limit, $search): array {
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('organism')
            ->from('AppBundle\Entity\Organism', 'organism')
            ->where('LOWER(organism.scientificName) LIKE LOWER(:search)')
            ->setParameter('search', $search)
            ->setMaxResults($limit);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        $data = array();
        for($i=0; $i<sizeof($result);$i++){
            $thisResult = array();
            $thisResult['fennec_id'] = $result[$i]['fennecId'];
            $thisResult['scientific_name'] = $result[$i]['scientificName'];
            $data[] = $thisResult;
        }
        return $data;
    }

    public function getDetailsOfOrganism($fennec_id){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('organism')
            ->from('AppBundle\Entity\Organism','organism')
            ->where('organism.fennecId = :id')
            ->setParameter('id', $fennec_id);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();

        $data = array();
        for($i=0; $i<sizeof($result);$i++) {
            $data['fennec_id'] = $result[$i]['fennecId'];
            $data['scientific_name'] = $result[$i]['scientificName'];
            $data['eol_identifier'] = $this->getIdentifierDbxref($result[$i]['fennecId'], 'EOL');
            $data['ncbi_identifier'] = $this->getIdentifierDbxref($result[$i]['fennecId'], 'ncbi_taxonomy');
        }
        return $result;
    }

    /**
     * @param int $fennec_id
     * @param string $db_name
     * @return string $identifier identifier of the current organism in the defined database
     */
    private function getIdentifierDbxref($fennec_id, $db_name)
    {
        $db_id = $this->getDBId($db_name);
        return $this->getIdentifier($fennec_id, $db_id);
    }

    private function getDBId($db_name){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('db.dbId')
            ->from('AppBundle\Entity\Db', 'db')
            ->where('db.name = :dbName')
            ->setParameter('dbName', $db_name);
        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        for($i=0; $i < sizeof($result); $i++) {
            $db_id = $result[$i]['dbId'];
        }
        if (!isset($db_id)) {
            return "";
        }
        return $db_id;
    }

    private function getIdentifier($fennec_id, $db_id){
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('d.identifier')
            ->from('AppBundle\Entity\FennecDbxref','d')
            ->where('d.db = :dbId')
            ->andWhere('d.fennec = :fennecId')
            ->setParameter('dbId',$db_id)
            ->setParameter('fennecId', $fennec_id);

        $query = $qb->getQuery();
        $result = $query->getArrayResult();
        for($i=0; $i < sizeof($result); $i++) {
            $identifier = $result[$i]['identifier'];
        }
        if (!isset($identifier)) {
            return "";
        }
        return $identifier;
    }
}

{'fraction_non_alphanumeric': 0.17334749137244493, 'fraction_numerical': 0.0010618529333687285, 'mean_word_length': 2.576174655908875, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3306254', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2297, 'n_words': 388}