<commit_before><?php

namespace TreeHouse\IoBundle\Entity;

use Doctrine\ORM\EntityRepository;
use TreeHouse\IoBundle\Exception\UnfinishedImportException;
use TreeHouse\IoBundle\Import\ImportResult;

class ImportRepository extends EntityRepository
{
    /**
     * Find scheduled imports by feed.
     *
     * @param Feed $feed
     *
     * @return Import[]
     */
    public function findScheduledByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')
            ->andWhere('i.datetimeStarted IS NULL')
            ->setParameter('feed', $feed)
        ;

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

    /**
     * Find latest started import.
     *
     * @return Import
     */
    public function findOneLatestStarted()
    {
        $builder = $this->createQueryBuilder('i')
            ->andWhere('i.datetimeStarted IS NOT NULL')
            ->orderBy('i.datetimeStarted', 'DESC')
            ->setMaxResults(1)
        ;

        return $builder->getQuery()->getOneOrNullResult();
    }

    /**
     * Find latest started import by feed.
     *
     * @param Feed $feed
     *
     * @return Import
     */
    public function findOneLatestStartedByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')
            ->andWhere('i.datetimeStarted IS NOT NULL')
            ->orderBy('i.datetimeStarted', 'DESC')
            ->setMaxResults(1)
            ->setParameter('feed', $feed)
        ;

        return $builder->getQuery()->getOneOrNullResult();
    }

    /**
     * Find imports by feed, ordered by descending start date.
     *
     * @param Feed $feed
     *
     * @return Import[]
     */
    public function findCompletedByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')<commit_msg>latest started import queries require at least one part<commit_after><?php

namespace TreeHouse\IoBundle\Entity;

use Doctrine\ORM\EntityRepository;
use TreeHouse\IoBundle\Exception\UnfinishedImportException;
use TreeHouse\IoBundle\Import\ImportResult;

class ImportRepository extends EntityRepository
{
    /**
     * Find scheduled imports by feed.
     *
     * @param Feed $feed
     *
     * @return Import[]
     */
    public function findScheduledByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')
            ->andWhere('i.datetimeStarted IS NULL')
            ->setParameter('feed', $feed)
        ;

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

    /**
     * Find latest started import.
     *
     * @return Import
     */
    public function findOneLatestStarted()
    {
        $builder = $this->createQueryBuilder('i')
            ->andWhere('i.datetimeStarted IS NOT NULL')
            ->andWhere('SIZE(i.parts) > 0')
            ->orderBy('i.datetimeStarted', 'DESC')
            ->setMaxResults(1)
        ;

        return $builder->getQuery()->getOneOrNullResult();
    }

    /**
     * Find latest started import by feed.
     *
     * @param Feed $feed
     *
     * @return Import
     */
    public function findOneLatestStartedByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')
            ->andWhere('i.datetimeStarted IS NOT NULL')
            ->andWhere('SIZE(i.parts) > 0')
            ->orderBy('i.datetimeStarted', 'DESC')
            ->setMaxResults(1)
            ->setParameter('feed', $feed)
        ;

        return $builder->getQuery()->getOneOrNullResult();
    }

    /**
     * Find imports by feed, ordered by descending start date.
     *
     * @param Feed $feed
     *
     * @return Import[]
     */
    public function findCompletedByFeed(Feed $feed)
    {
        $builder = $this->createQueryBuilder('i')
            ->where('i.feed = :feed')
{'fraction_non_alphanumeric': 0.1354378818737271, 'fraction_numerical': 0.0015274949083503055, 'mean_word_length': 2.1207307386814933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '2396837', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1116, 'n_words': 231}