<commit_before><?php

namespace App\Entity\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\AbstractQuery;
use App\Entity\DTO\CurriculumInventorySequenceBlockDTO;

/**
 * Class CurriculumInventorySequenceBlockRepository
 */
class CurriculumInventorySequenceBlockRepository extends EntityRepository implements DTORepositoryInterface
{
    /**
     * @inheritdoc
     */
    public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $qb = $this->_em->createQueryBuilder();
        $qb->select('DISTINCT x')->from('App\Entity\CurriculumInventorySequenceBlock', 'x');

        $this->attachCriteriaToQueryBuilder($qb, $criteria, $orderBy, $limit, $offset);

        return $qb->getQuery()->getResult();
    }

    /**
     * Find and hydrate as DTOs
     *
     * @param array $criteria
     * @param array|null $orderBy
     * @param null $limit
     * @param null $offset
     *
     * @return array
     */
    public function findDTOsBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $qb = $this->_em->createQueryBuilder()->select('x')
            ->distinct()->from('App\Entity\CurriculumInventorySequenceBlock', 'x');
        $this->attachCriteriaToQueryBuilder($qb, $criteria, $orderBy, $limit, $offset);

        /** @var CurriculumInventorySequenceBlockDTO[] $sequenceBlockDTOs */
        $sequenceBlockDTOs = [];
        foreach ($qb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY) as $arr) {
            $sequenceBlockDTOs[$arr['id']] = new CurriculumInventorySequenceBlockDTO(
                $arr['id'],
                $arr['title'],
                $arr['description'],
                $arr['required'],
                $arr['childSequenceOrder'],
                $arr['orderInSequence'],
                $arr['minimum'],
                $arr['maximum'],
                $arr['track'],
                $arr['startDate'],
                $arr['endDate'],
                $arr['duration']
            );
        }
        $curriculumInventorySequenceBlockIds = array_keys($sequenceBlockDTOs);

        $qb = $this->_em->createQueryBuilder()
            ->select(
                'x.id as xId, report.id AS reportId, school.id AS schoolId, ' .
                'academicLevel.id AS academicLevelId, course.id AS courseId, parent.id AS parentId '
            )
            ->from('App\Entity\CurriculumInventorySequenceBlock', 'x')
            ->join('x.report', 'report')
            ->join('report.program', 'program')
            ->join('program.school', 'school')
            ->leftJoin('x.parent', 'parent')
            ->leftJoin('x.course', 'course')
            ->leftJoin('x.academicLevel', 'academicLevel')
            ->where($qb->expr()->in('x.id', ':ids'))
            ->setParameter('ids', $curriculumInventorySequenceBlockIds);

        foreach ($qb->getQuery()->getResult() as $arr) {
            $sequenceBlockDTOs[$arr['xId']]->report = (int) $arr['reportId'];
            $sequenceBlockDTOs[$arr['xId']]->academicLevel = $arr['academicLevelId'] ? (int)$arr['academicLevelId'] : null;
            $sequenceBlockDTOs[$arr['xId']]->course = $arr['courseId'] ? (int)$arr['courseId'] : null;
            $sequenceBlockDTOs[$arr['xId']]->parent = $arr['parentId'] ? (int)$arr['parentId'] : null;<commit_msg>Fix line length<commit_after><?php

namespace App\Entity\Repository;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\AbstractQuery;
use App\Entity\DTO\CurriculumInventorySequenceBlockDTO;

/**
 * Class CurriculumInventorySequenceBlockRepository
 */
class CurriculumInventorySequenceBlockRepository extends EntityRepository implements DTORepositoryInterface
{
    /**
     * @inheritdoc
     */
    public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $qb = $this->_em->createQueryBuilder();
        $qb->select('DISTINCT x')->from('App\Entity\CurriculumInventorySequenceBlock', 'x');

        $this->attachCriteriaToQueryBuilder($qb, $criteria, $orderBy, $limit, $offset);

        return $qb->getQuery()->getResult();
    }

    /**
     * Find and hydrate as DTOs
     *
     * @param array $criteria
     * @param array|null $orderBy
     * @param null $limit
     * @param null $offset
     *
     * @return array
     */
    public function findDTOsBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $qb = $this->_em->createQueryBuilder()->select('x')
            ->distinct()->from('App\Entity\CurriculumInventorySequenceBlock', 'x');
        $this->attachCriteriaToQueryBuilder($qb, $criteria, $orderBy, $limit, $offset);

        /** @var CurriculumInventorySequenceBlockDTO[] $sequenceBlockDTOs */
        $sequenceBlockDTOs = [];
        foreach ($qb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY) as $arr) {
            $sequenceBlockDTOs[$arr['id']] = new CurriculumInventorySequenceBlockDTO(
                $arr['id'],
                $arr['title'],
                $arr['description'],
                $arr['required'],
                $arr['childSequenceOrder'],
                $arr['orderInSequence'],
                $arr['minimum'],
                $arr['maximum'],
                $arr['track'],
                $arr['startDate'],
                $arr['endDate'],
                $arr['duration']
            );
        }
        $curriculumInventorySequenceBlockIds = array_keys($sequenceBlockDTOs);

        $qb = $this->_em->createQueryBuilder()
            ->select(
                'x.id as xId, report.id AS reportId, school.id AS schoolId, ' .
                'academicLevel.id AS academicLevelId, course.id AS courseId, parent.id AS parentId '
            )
            ->from('App\Entity\CurriculumInventorySequenceBlock', 'x')
            ->join('x.report', 'report')
            ->join('report.program', 'program')
            ->join('program.school', 'school')
            ->leftJoin('x.parent', 'parent')
            ->leftJoin('x.course', 'course')
            ->leftJoin('x.academicLevel', 'academicLevel')
            ->where($qb->expr()->in('x.id', ':ids'))
            ->setParameter('ids', $curriculumInventorySequenceBlockIds);

        foreach ($qb->getQuery()->getResult() as $arr) {
            $sequenceBlockDTOs[$arr['xId']]->report = (int) $arr['reportId'];
            $sequenceBlockDTOs[$arr['xId']]->academicLevel =
                $arr['academicLevelId'] ? (int)$arr['academicLevelId'] : null;
            $sequenceBlockDTOs[$arr['xId']]->course = $arr['courseId'] ? (int)$arr['courseId'] : null;
            $sequenceBlockDTOs[$arr['xId']]->parent = $arr['parentId'] ? (int)$arr['parentId'] : null;
{'fraction_non_alphanumeric': 0.1608888888888889, 'fraction_numerical': 0.0, 'mean_word_length': 2.596696856686201, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 73, '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': '3403486', 'n_tokens_mistral': 1978, 'n_tokens_neox': 1973, 'n_words': 331}