<commit_before><?php

class BatchTable extends Doctrine_Table
{
    public function countSplits($batch_id)
    {
        $batch = $this->createQuery('b')
          //  ->select('b.id, a.id, s.id')
            ->where('b.id = ?', $batch_id)
            ->leftJoin('b.Analysis a')
            ->leftJoin('a.Split s')
            ->fetchOne();

        $count = 0;
        foreach ($batch->Analysis as $a) {
            $count += $batch->Split->count();
        }
        return $count;
    }

    /**
     * Fetches a batch object with Al and Be carrier data.
     *
     * @return Batch
     **/
    public function findWithCarriers($id)
    {
        return Doctrine_Query::create()
            ->from('Batch b')
            ->leftJoin('b.Analysis a')
            ->leftJoin('b.BeCarrier bec')
            ->leftJoin('b.AlCarrier alc')
            ->where('b.id = ?', $id)
            ->fetchOne();
    }

    /**
     *
     * @return Batch
     */
    public function findOpenBatches()
    {
        return Doctrine_Query::create()
            ->from('Batch b')
            ->select('b.id, b.owner, b.description, b.start_date')
            ->where('completed = ?', 'n')
            ->orderBy('b.start_date desc')
            ->execute();
    }

    /**
     *
     * @return Batch
     */
    public function findAllBatches()
    {
        return Doctrine_Query::create()
            ->from('Batch b')<commit_msg>Need proper ordering for analyses on batch queries.<commit_after><?php

class BatchTable extends Doctrine_Table
{
    public function countSplits($batch_id)
    {
        $batch = $this->createQuery('b')
          //  ->select('b.id, a.id, s.id')
            ->where('b.id = ?', $batch_id)
            ->leftJoin('b.Analysis a')
            ->leftJoin('a.Split s')
            ->fetchOne();

        $count = 0;
        foreach ($batch->Analysis as $a) {
            $count += $batch->Split->count();
        }
        return $count;
    }

    /**
     * Fetches a batch object with Al and Be carrier data.
     *
     * @return Batch
     **/
    public function findWithCarriers($id)
    {
        return Doctrine_Query::create()
            ->from('Batch b')
            ->leftJoin('b.Analysis a')
            ->leftJoin('b.BeCarrier bec')
            ->leftJoin('b.AlCarrier alc')
            ->where('b.id = ?', $id)
            ->orderBy('a.id ASC')
            ->fetchOne();
    }

    /**
     *
     * @return Batch
     */
    public function findOpenBatches()
    {
        return Doctrine_Query::create()
            ->from('Batch b')
            ->select('b.id, b.owner, b.description, b.start_date')
            ->where('completed = ?', 'n')
            ->orderBy('b.start_date desc')
            ->execute();
    }

    /**
     *
     * @return Batch
     */
    public function findAllBatches()
    {
        return Doctrine_Query::create()
            ->from('Batch b')
{'fraction_non_alphanumeric': 0.16046831955922866, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 1.5730735163861824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, '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': '2971722', 'n_tokens_mistral': 897, 'n_tokens_neox': 878, 'n_words': 178}