<commit_before><?php

namespace SyntaxError\ApiBundle\Repository;

use Doctrine\ORM\EntityRepository;
use SyntaxError\ApiBundle\Tools\Uniter;
use SyntaxError\ApiBundle\Entity\Archive;

/**
 * archiveRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class ArchiveRepository extends EntityRepository
{
    /**
     * @return null|Archive
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
    public function findLast()
    {
        return $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")->createQueryBuilder('a')
            ->orderBy('a.dateTime', 'desc')->setMaxResults(1)->getQuery()->getOneOrNullResult();
    }

    /**
     * @param $archiveProperty
     * @return float|int
     */
    public function getLastTrend($archiveProperty)
    {
        $archives = $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")->createQueryBuilder('a')
            ->select("a.$archiveProperty")->orderBy('a.dateTime', 'desc')->setMaxResults(12)->getQuery()->getResult();
        if(!$archives) return 0;
        return Uniter::getTrend($archives, $archiveProperty);
    }

    /**
     * @param \DateTime $dateTime
     * @return array|Archive[]
     */
    public function findByDay(\DateTime $dateTime)
    {
        $from = new \DateTime($dateTime->format("Y-m-d H:i:s"));
        $to = new \DateTime($dateTime->format("Y-m-d H:i:s"));
        $from->setTime(0,0,0);
        $to->setTime(23,59,59);
        return $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")
            ->createQueryBuilder('a')
            ->where('a.dateTime BETWEEN :from AND :to')
            ->setParameter( 'from', $from->getTimestamp() )
            ->setParameter( 'to', $to->getTimestamp() )
            ->getQuery()->getResult();
    }

    /**
     * @return mixed
     * @throws \Doctrine\ORM\NonUniqueResultException
     */<commit_msg>more samples for trend calculation<commit_after><?php

namespace SyntaxError\ApiBundle\Repository;

use Doctrine\ORM\EntityRepository;
use SyntaxError\ApiBundle\Tools\Uniter;
use SyntaxError\ApiBundle\Entity\Archive;

/**
 * archiveRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class ArchiveRepository extends EntityRepository
{
    /**
     * @return null|Archive
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
    public function findLast()
    {
        return $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")->createQueryBuilder('a')
            ->orderBy('a.dateTime', 'desc')->setMaxResults(1)->getQuery()->getOneOrNullResult();
    }

    /**
     * @param $archiveProperty
     * @return float|int
     */
    public function getLastTrend($archiveProperty)
    {
        $archives = $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")->createQueryBuilder('a')
            ->select("a.$archiveProperty")->orderBy('a.dateTime', 'desc')->setMaxResults(24)->getQuery()->getResult();
        if(!$archives) return 0;
        return Uniter::getTrend($archives, $archiveProperty);
    }

    /**
     * @param \DateTime $dateTime
     * @return array|Archive[]
     */
    public function findByDay(\DateTime $dateTime)
    {
        $from = new \DateTime($dateTime->format("Y-m-d H:i:s"));
        $to = new \DateTime($dateTime->format("Y-m-d H:i:s"));
        $from->setTime(0,0,0);
        $to->setTime(23,59,59);
        return $this->getEntityManager()->getRepository("SyntaxErrorApiBundle:Archive")
            ->createQueryBuilder('a')
            ->where('a.dateTime BETWEEN :from AND :to')
            ->setParameter( 'from', $from->getTimestamp() )
            ->setParameter( 'to', $to->getTimestamp() )
            ->getQuery()->getResult();
    }

    /**
     * @return mixed
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
{'fraction_non_alphanumeric': 0.1577479076845042, 'fraction_numerical': 0.006593963986812072, 'mean_word_length': 3.121212121212121, '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': '3137182', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1144, 'n_words': 194}