<commit_before><?php

namespace MagicWordBundle\Repository;

use MagicWordBundle\Entity\Player;
use Innova\LexiconBundle\Entity\Language;

/**
 * GameRepository.
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class GameRepository extends \Doctrine\ORM\EntityRepository
{
    public function findNotPlayedForTraining(Player $user, Language $language)
    {
        $em = $this->_em;
        $dql = "SELECT game FROM MagicWordBundle\Entity\Game game
                LEFT JOIN game.rounds r
                WHERE r.language = :language
                AND game INSTANCE OF 'MagicWordBundle\Entity\GameType\Training'
                AND NOT EXISTS(
                    SELECT a FROM MagicWordBundle\Entity\Activity a
                    WHERE a.round = r
                    AND a.player = :user
                )";

        $query = $em->createQuery($dql);
        $query->setParameter('user', $user)
              ->setParameter('language', $language)
              ->setMaxResults(1);

        return $query->getOneOrNullResult();
    }
}
<commit_msg>restrict picking grid for training when it has more than 150 foundables<commit_after><?php

namespace MagicWordBundle\Repository;

use MagicWordBundle\Entity\Player;
use Innova\LexiconBundle\Entity\Language;

/**
 * GameRepository.
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class GameRepository extends \Doctrine\ORM\EntityRepository
{
    public function findNotPlayedForTraining(Player $user, Language $language)
    {
        $em = $this->_em;
        $dql = "SELECT game FROM MagicWordBundle\Entity\Game game
                LEFT JOIN game.rounds r
                LEFT JOIN r.grid g
                WHERE r.language = :language
                AND game INSTANCE OF 'MagicWordBundle\Entity\GameType\Training'
                AND NOT EXISTS(
                    SELECT a FROM MagicWordBundle\Entity\Activity a
                    WHERE a.round = r
                    AND a.player = :user
                )
                AND SIZE(g.foundableForms) > 150";

        $query = $em->createQuery($dql);
        $query->setParameter('user', $user)
              ->setParameter('language', $language)
              ->setMaxResults(1);

        return $query->getOneOrNullResult();
    }
}

{'fraction_non_alphanumeric': 0.09202714164546226, 'fraction_numerical': 0.0033927056827820186, 'mean_word_length': 2.095800524934383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '6882174', 'n_tokens_mistral': 654, 'n_tokens_neox': 606, 'n_words': 170}