<commit_before><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class MySavedSearchesTable extends DarwinTable
{
  public function addUserOrder(Doctrine_Query $q = null,$user)
  {
    if (is_null($q))
    {
        $q = Doctrine_Query::create()
            ->from('MySavedSearches s');
    }
    $alias = $q->getRootAlias();
    $q->andWhere($alias . '.user_ref = ?', $user)
        ->orderBy($alias . '.favorite DESC');
    return $q;
  }

  public function addIsSearch(Doctrine_Query $q, $is_search = false)
  {
    $q->andWhere($q->getRootAlias() . '.is_only_id = ?', !$is_search);
    return $q;
  }
  
  public function getSavedSearchByKey($id, $user )
  {
    return $this->addUserOrder(null, $user)
      ->andWhere('id = ?', $id )
      ->fetchOne();
  }

  public function fetchSearch($user_ref, $num_per_page)
  {
    $q = $this->addUserOrder(null,$user_ref);
    $this->addIsSearch($q, true);
    $q->limit($num_per_page);

    return $q->execute();
  }

  public function fetchSpecimens($user_ref, $num_per_page)
  {
    $q = $this->addUserOrder(null,$user_ref);
    $this->addIsSearch($q, false);
    $q->limit($num_per_page);

    return $q->execute();
  }

  public function getListFor($user, $source)
  {
    $q = $this->addUserOrder(null,$user);
    $this->addIsSearch($q, false);
    return $q->andWhere('subject = ?',$source)->execute();
  }

  public function getAllFields($source, $is_reg_user = false)
  {
    $part_col = array();
    $individual_col = array();
    $specimen_col = array(
      'category'=>'Category',
      'collection'=>'Collection',
      'taxon'=>'Taxon',
      'type'=>'Type',
      'gtu'=>'Sampling Location',
      'codes'=>'Codes',
      'chrono'=>'Chronostratigraphy',
      'ig'=>'Inv. General',
      'litho'=>'Lithostratigraphy',
      'lithologic'=>'Lithology',
      'expedition'=>'Expedition',
      'mineral'=>'Mineralogy',
      'count'=>'Count',
      'acquisition_category' => 'Acquisition category'
    );
    if($source == 'individual' || $source == 'part')
    {
      $individual_col = array(
        'individual_type' => 'Individual Type',
        'sex' => 'Sex',
        'state' => 'State',
        'stage'=> 'Stage',
        'social_status' =>'Social Status',
        'rock_form'=>'Rock Form',
        'individual_count'=>'Individual Count',
      );
    }

    if($source == 'part')
    {
      if($is_reg_user)
      {
        $part_col = array(
          'part' => 'Part',
          'part_status'=>'Part Status',
          'part_code'=>'Part Code',
          'part_count'=>'Part Count',
        );      
      }
      else
      {
        $part_col = array(
          'part'=>'Part',
          'part_status'=>'Part Status',
          'building'=>'Building',
          'floor'=>'Floor',
          'room'=>'Room',
          'row'=>'Row',
          'shelf'=>'Shelf',
          'container'=>'Container',
          'container_type'=>'Container Type',
          'container_storage'=>'Container Storage',
          'sub_container'=>'Sub Container',
          'sub_container_type'=>'Sub Container Type',
          'sub_container_storage'=>'Sub Container Storage',
          'part_code'=>'Part Code',
          'part_count'=>'Part Count',<commit_msg>Correct Default column for part codes<commit_after><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class MySavedSearchesTable extends DarwinTable
{
  public function addUserOrder(Doctrine_Query $q = null,$user)
  {
    if (is_null($q))
    {
        $q = Doctrine_Query::create()
            ->from('MySavedSearches s');
    }
    $alias = $q->getRootAlias();
    $q->andWhere($alias . '.user_ref = ?', $user)
        ->orderBy($alias . '.favorite DESC');
    return $q;
  }

  public function addIsSearch(Doctrine_Query $q, $is_search = false)
  {
    $q->andWhere($q->getRootAlias() . '.is_only_id = ?', !$is_search);
    return $q;
  }
  
  public function getSavedSearchByKey($id, $user )
  {
    return $this->addUserOrder(null, $user)
      ->andWhere('id = ?', $id )
      ->fetchOne();
  }

  public function fetchSearch($user_ref, $num_per_page)
  {
    $q = $this->addUserOrder(null,$user_ref);
    $this->addIsSearch($q, true);
    $q->limit($num_per_page);

    return $q->execute();
  }

  public function fetchSpecimens($user_ref, $num_per_page)
  {
    $q = $this->addUserOrder(null,$user_ref);
    $this->addIsSearch($q, false);
    $q->limit($num_per_page);

    return $q->execute();
  }

  public function getListFor($user, $source)
  {
    $q = $this->addUserOrder(null,$user);
    $this->addIsSearch($q, false);
    return $q->andWhere('subject = ?',$source)->execute();
  }

  public function getAllFields($source, $is_reg_user = false)
  {
    $part_col = array();
    $individual_col = array();
    $specimen_col = array(
      'category'=>'Category',
      'collection'=>'Collection',
      'taxon'=>'Taxon',
      'type'=>'Type',
      'gtu'=>'Sampling Location',
      'codes'=>'Codes',
      'chrono'=>'Chronostratigraphy',
      'ig'=>'Inv. General',
      'litho'=>'Lithostratigraphy',
      'lithologic'=>'Lithology',
      'expedition'=>'Expedition',
      'mineral'=>'Mineralogy',
      'count'=>'Count',
      'acquisition_category' => 'Acquisition category'
    );
    if($source == 'individual' || $source == 'part')
    {
      $individual_col = array(
        'individual_type' => 'Individual Type',
        'sex' => 'Sex',
        'state' => 'State',
        'stage'=> 'Stage',
        'social_status' =>'Social Status',
        'rock_form'=>'Rock Form',
        'individual_count'=>'Individual Count',
      );
    }

    if($source == 'part')
    {
      if($is_reg_user)
      {
        $part_col = array(
          'part' => 'Part',
          'part_status'=>'Part Status',
          'part_codes'=>'Part Code',
          'part_count'=>'Part Count',
        );      
      }
      else
      {
        $part_col = array(
          'part'=>'Part',
          'part_status'=>'Part Status',
          'building'=>'Building',
          'floor'=>'Floor',
          'room'=>'Room',
          'row'=>'Row',
          'shelf'=>'Shelf',
          'container'=>'Container',
          'container_type'=>'Container Type',
          'container_storage'=>'Container Storage',
          'sub_container'=>'Sub Container',
          'sub_container_type'=>'Sub Container Type',
          'sub_container_storage'=>'Sub Container Storage',
          'part_codes'=>'Part Code',
          'part_count'=>'Part Count',
{'fraction_non_alphanumeric': 0.18310291858678956, 'fraction_numerical': 0.0, 'mean_word_length': 2.6619797525309337, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 125, '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': '1363825', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2129, 'n_words': 368}