<commit_before><?php

/*
 * This file is part of the gumnut package.
 * (c) 2009-2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * PlugingnPageTable
 *
 * @package    gumnut
 * @subpackage model
 * @author     <NAME> <<EMAIL>>
 */
class PlugingnPageTable extends Doctrine_Table
{
  public function findAllPublished(Doctrine_Query $query = null)
  {
    $query = $this->addPublishedQuery($query);
    return $query->andWhere('page.deleted_at IS NULL')->execute();
  }

  public function findAllPages(Doctrine_Query $query = null)
  {
    return $this->getQuery($query)->andWhere('page.deleted_at IS NULL')->execute();
  }

  public function addPublishedQuery(Doctrine_Query $query = null)
  {
    $query = $this->getQuery($query);
    $query->andWhere('(page.published_from < ? OR page.published_from IS NULL)', date('Y-m-d H:i:s', time()));
    $query->andWhere('(page.published_to > ? OR page.published_to IS NULL)', date('Y-m-d H:i:s', time()));
    $query->andWhere('page.published = 1');
    return $query;
  }

  /**
   * Return a query object, creting a new one if needed.
   *
   * @param Doctrine_Query $query
   * @param string $alias
   * @return Doctrine_Query
   */
  public function getQuery(Doctrine_Query $query = null)
  {
    if(is_null($query))
    {
      return parent::createQuery('page');
    }
    return $query;
  }
}<commit_msg>Revised handling of the not-deleted query<commit_after><?php

/*
 * This file is part of the gumnut package.
 * (c) 2009-2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * PlugingnPageTable
 *
 * @package    gumnut
 * @subpackage model
 * @author     <NAME> <<EMAIL>>
 */
class PlugingnPageTable extends Doctrine_Table
{
  public function findAllPublished(Doctrine_Query $query = null)
  {
    $query = $this->addPublishedQuery($query);
    return $query->andWhere('page.deleted_at IS NULL')->execute();
  }

  public function findAllPages(Doctrine_Query $query = null)
  {
    return $this->addNotDeletedQuery()->execute();
  }

  public function addNotDeletedQuery(Doctrine_Query $query = null)
  {
    return $this->getQuery($query)->andWhere('page.deleted_at IS NULL');
  }

  public function addPublishedQuery(Doctrine_Query $query = null)
  {
    $query = $this->getQuery($query);
    $query->andWhere('(page.published_from < ? OR page.published_from IS NULL)', date('Y-m-d H:i:s', time()));
    $query->andWhere('(page.published_to > ? OR page.published_to IS NULL)', date('Y-m-d H:i:s', time()));
    $query->andWhere('page.published = 1');
    return $query;
  }

  /**
   * Return a query object, creting a new one if needed.
   *
   * @param Doctrine_Query $query
   * @param string $alias
   * @return Doctrine_Query
   */
  public function getQuery(Doctrine_Query $query = null)
  {
    if(is_null($query))
    {
      return parent::createQuery('page');
    }
    return $query;
  }
}
{'fraction_non_alphanumeric': 0.145224171539961, 'fraction_numerical': 0.005847953216374269, 'mean_word_length': 3.6722306525037935, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 38, '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': '2485947', 'n_tokens_mistral': 1019, 'n_tokens_neox': 993, 'n_words': 250}