<commit_before><?php

class darwinImportTask extends sfBaseTask
{

  protected function configure()
  {
    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),      
      ));      
    $this->namespace        = 'darwin';
    $this->name             = 'process-import';
    $this->briefDescription = 'Import uploaded file to potgresql temp table';
    $this->detailedDescription = <<<EOF
Nothing
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
     // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $environment = $this->configuration instanceof sfApplicationConfiguration ? $this->configuration->getEnvironment() : $options['env']; 
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
    $conn = Doctrine_Manager::connection();
    $conn->getDbh()->exec('BEGIN TRANSACTION;');
    while($id = $conn->fetchOne('SELECT get_import_rows()'))  
    {
        $q = Doctrine_Query::create()
          ->from('imports p')
          ->where('p.id=?',$id)
          ->fetchOne() ;
        $file = sfConfig::get('sf_upload_dir').'/uploaded_'.sha1($q->getFilename().$q->getCreatedAt()).'.xml' ;    
        if(file_exists($file))
        {
          try{
            $import = new importDnaXml() ;
            $import->importFile($file,$id) ;
          }
          catch(Exception $e)
          {
            echo $e->getMessage()."\n";break;
          }
          Doctrine_Query::create()
            ->update('imports p')
            ->set('p.state','?','loaded')
            ->set('p.initial_count','(select count(*) from staging where import_ref = ? )',$id)
            ->where('p.id = ?', $id)
            ->execute();
        }              
    }
    $conn->getDbh()->exec('COMMIT;');

  }
}  
<commit_msg>Correct import task to use the new function<commit_after><?php

class darwinImportTask extends sfBaseTask
{

  protected function configure()
  {
    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'),
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),      
      ));      
    $this->namespace        = 'darwin';
    $this->name             = 'process-import';
    $this->briefDescription = 'Import uploaded file to potgresql temp table';
    $this->detailedDescription = <<<EOF
Nothing
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
     // initialize the database connection
    $databaseManager = new sfDatabaseManager($this->configuration);
    $environment = $this->configuration instanceof sfApplicationConfiguration ? $this->configuration->getEnvironment() : $options['env']; 
    $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
    $conn = Doctrine_Manager::connection();
    $conn->getDbh()->exec('BEGIN TRANSACTION;');
    while($id = $conn->fetchOne('SELECT get_import_row()'))  
    {
        $q = Doctrine_Query::create()
          ->from('imports p')
          ->where('p.id=?',$id)
          ->fetchOne() ;
        $file = sfConfig::get('sf_upload_dir').'/uploaded_'.sha1($q->getFilename().$q->getCreatedAt()).'.xml' ;    
        if(file_exists($file))
        {
          try{
            $import = new importDnaXml() ;
            $import->importFile($file,$id) ;
          }
          catch(Exception $e)
          {
            echo $e->getMessage()."\n";break;
          }
          Doctrine_Query::create()
            ->update('imports p')
            ->set('p.state','?','loaded')
            ->set('p.initial_count','(select count(*) from staging where import_ref = ? )',$id)
            ->where('p.id = ?', $id)
            ->execute();
        }              
    }
    $conn->getDbh()->exec('COMMIT;');

  }
}  

{'fraction_non_alphanumeric': 0.16508230929747275, 'fraction_numerical': 0.0004637143519591931, 'mean_word_length': 2.751304347826087, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2997231', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1221, 'n_words': 223}