<commit_before><?php

namespace AmbigussBundle\Repository;

/**
 * MotAmbiguPhraseRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class MotAmbiguPhraseRepository extends \Doctrine\ORM\EntityRepository
{
	public function findByIdPhrase($idPhrase){
		return $this->createQueryBuilder('pma')
			->innerJoin("pma.motAmbigu", "ma", "WITH", "pma.motAmbigu = ma.id")->addSelect("ma")
			->innerJoin("ma.gloses", "g")->addSelect("g")
			->where("pma.phrase = :phrase")->setParameter("phrase", $idPhrase)
			->getQuery()->getResult();
	}

	/**
	 * Retoune un tableau de tableau avec un champ correspondant à l'id d'une phrase non joué et existante depuis plus de $dureeAv par l'ip depuis since
	 *
	 * @param $ip
	 * @param $since
	 * @param $maxResult
	 * @param $dureeAvantJouabiliteSecondes
	 *
	 * @return array
	 */
	public function findIdPhrasesNotPlayedByIpSince($ip, $since, $maxResult, $dureeAvantJouabiliteSecondes)
	{
		$date = new \DateTime();
		$dateMin = $date->setTimestamp($date->getTimestamp() - $dureeAvantJouabiliteSecondes);

		return $this->createQueryBuilder('pma')->select('identity(pma.phrase) id')->distinct()
			->leftJoin('pma.reponses', 'r', "WITH", "pma.id = r.motAmbiguPhrase AND r.ip = :ip AND r.dateReponse >= :since")
			->join('pma.phrase', 'p', "WITH", "pma.phrase = p.id")
			->setParameter('ip', $ip)->setParameter('since', $since)
			->where('r.id is null')
			->andWhere('p.dateCreation < :dateMin')->setParameter('dateMin', $dateMin->format('Y-m-d H:i:s'))
			->setMaxResults($maxResult)
			->getQuery()->getArrayResult();
	}

	/**
	 * Retourne un tableau de tableau avec un champ correspondant à l'id d'une phrase et existante depuis plus de $dureeAv
	 * @param $dureeAvantJouabiliteSecondes
	 *
	 * @return array
	 */
	public function findAllIdPhrases($dureeAvantJouabiliteSecondes)
	{
		$date = new \DateTime();
		$dateMin = $date->setTimestamp($date->getTimestamp() - $dureeAvantJouabiliteSecondes);
		return $this->createQueryBuilder('pma')->select('identity(pma.phrase)')
			->leftJoin('pma.reponses', 'r', "WITH", "pma.id = r.motAmbiguPhrase")
			->join('pma.phrase', 'p', "WITH", "pma.phrase = p.id")
			->where('p.dateCreation < :dateMin')->setParameter('dateMin', $dateMin->format('Y-m-d H:i:s'))
			->groupBy('pma.phrase')
			->getQuery()->getArrayResult();
	}

}<commit_msg>Fix erreur 500 quand toutes les phrases ont été jouées<commit_after><?php

namespace AmbigussBundle\Repository;

/**
 * MotAmbiguPhraseRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class MotAmbiguPhraseRepository extends \Doctrine\ORM\EntityRepository
{
	public function findByIdPhrase($idPhrase){
		return $this->createQueryBuilder('pma')
			->innerJoin("pma.motAmbigu", "ma", "WITH", "pma.motAmbigu = ma.id")->addSelect("ma")
			->innerJoin("ma.gloses", "g")->addSelect("g")
			->where("pma.phrase = :phrase")->setParameter("phrase", $idPhrase)
			->getQuery()->getResult();
	}

	/**
	 * Retoune un tableau de tableau avec un champ correspondant à l'id d'une phrase non joué et existante depuis plus de $dureeAv par l'ip depuis since
	 *
	 * @param $ip
	 * @param $since
	 * @param $maxResult
	 * @param $dureeAvantJouabiliteSecondes
	 *
	 * @return array
	 */
	public function findIdPhrasesNotPlayedByIpSince($ip, $since, $maxResult, $dureeAvantJouabiliteSecondes)
	{
		$date = new \DateTime();
		$dateMin = $date->setTimestamp($date->getTimestamp() - $dureeAvantJouabiliteSecondes);

		return $this->createQueryBuilder('pma')->select('identity(pma.phrase) id')->distinct()
			->leftJoin('pma.reponses', 'r', "WITH", "pma.id = r.motAmbiguPhrase AND r.ip = :ip AND r.dateReponse >= :since")
			->join('pma.phrase', 'p', "WITH", "pma.phrase = p.id")
			->setParameter('ip', $ip)->setParameter('since', $since)
			->where('r.id is null')
			->andWhere('p.dateCreation < :dateMin')->setParameter('dateMin', $dateMin->format('Y-m-d H:i:s'))
			->setMaxResults($maxResult)
			->getQuery()->getArrayResult();
	}

	/**
	 * Retourne un tableau de tableau avec un champ correspondant à l'id d'une phrase et existante depuis plus de $dureeAv
	 * @param $dureeAvantJouabiliteSecondes
	 *
	 * @return array
	 */
	public function findAllIdPhrases($dureeAvantJouabiliteSecondes)
	{
		$date = new \DateTime();
		$dateMin = $date->setTimestamp($date->getTimestamp() - $dureeAvantJouabiliteSecondes);

		return $this->createQueryBuilder('pma')->select('identity(pma.phrase) id')
			->leftJoin('pma.reponses', 'r', "WITH", "pma.id = r.motAmbiguPhrase")
			->join('pma.phrase', 'p', "WITH", "pma.phrase = p.id")
			->where('p.dateCreation < :dateMin')->setParameter('dateMin', $dateMin->format('Y-m-d H:i:s'))
			->groupBy('pma.phrase')
			->getQuery()->getArrayResult();
	}

}
{'fraction_non_alphanumeric': 0.17736240913811008, 'fraction_numerical': 0.0006230529595015577, 'mean_word_length': 4.873170731707317, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 79, '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': '4439421', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1688, 'n_words': 344}