<commit_before><?php
declare(strict_types=1);

namespace AppBundle\Action\Image;

use Doctrine\ORM\EntityManager;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Annotation\Route;

class EnrichAction
{
    /**
     * @var ContainerInterface
     */
    protected $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * @Route(
     *     name="enrich",
     *     path="/images-enrich"
     * )
     * @Method("GET")
     *
     * @return mixed
     */
    public function __invoke()
    {
        $em = $this->entityManager;

        $imageCount = $em->createQueryBuilder()
            ->select('count(i.id)')
            ->from('AppBundle\Entity\Image', 'i')
            ->getQuery()
            ->getSingleScalarResult();

        $randomImage = $em->createQueryBuilder()
            ->select('i')
            ->from('AppBundle\Entity\Image', 'i')
            ->setMaxResults(1)
            ->setFirstResult(rand(1, intval($imageCount)))
            ->getQuery()
            ->getResult();

        $metadataCount = $em->createQueryBuilder()
            ->select('count(m)')
            ->from('AppBundle\Entity\Metadata', 'm')
            ->getQuery()
            ->getSingleScalarResult();

        $randomMetadata = $em->createQueryBuilder()
            ->select('m')
            ->from('AppBundle\Entity\Metadata', 'm')
            ->setMaxResults(1)
            ->setFirstResult(rand(1, $metadataCount))
            ->getQuery()
            ->getResult();

        $obj = new \stdClass();
        $obj->image = $randomImage;
        $obj->metadata = $randomMetadata;
        $obj->question = 'The big question?';

        return $obj;
    }
}<commit_msg>(feat) enrich action<commit_after><?php
declare(strict_types=1);

namespace AppBundle\Action\Image;

use Doctrine\ORM\EntityManager;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Annotation\Route;

class EnrichAction
{
    /**
     * @var ContainerInterface
     */
    protected $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * @Route(
     *     name="enrich",
     *     path="/images-enrich"
     * )
     * @Method("GET")
     *
     * @return mixed
     */
    public function __invoke()
    {
        $em = $this->entityManager;

        $imageCount = $em->createQueryBuilder()
            ->select('count(i.id)')
            ->from('AppBundle\Entity\Image', 'i')
            ->getQuery()
            ->getSingleScalarResult();

        $randomImage = $em->createQueryBuilder()
            ->select('i')
            ->from('AppBundle\Entity\Image', 'i')
            ->setMaxResults(1)
            ->setFirstResult(rand(1, intval($imageCount)))
            ->getQuery()
            ->getResult();

        $metadataCount = $em->createQueryBuilder()
            ->select('count(m)')
            ->from('AppBundle\Entity\Metadata', 'm')
            ->getQuery()
            ->getSingleScalarResult();

        $randomMetadata = $em->createQueryBuilder()
            ->select('m')
            ->from('AppBundle\Entity\Metadata', 'm')
            ->setMaxResults(1)
            ->setFirstResult(rand(1, intval($metadataCount)))
            ->getQuery()
            ->getResult();

        $obj = new \stdClass();
        $obj->image = $randomImage;
        $obj->metadata = $randomMetadata;
        $obj->question = 'The big question?';

        return $obj;
    }
}
{'fraction_non_alphanumeric': 0.15166889185580773, 'fraction_numerical': 0.0026702269692923898, 'mean_word_length': 2.098428453267163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '4322207', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1050, 'n_words': 166}