<commit_before><?php

class DRChangeDateTask extends sfBaseTask
{

    protected function configure()
    {
        $this->addArguments(array(
          new sfCommandArgument('id', sfCommandArgument::REQUIRED, 'id'),
          new sfCommandArgument('date', sfCommandArgument::REQUIRED, 'date'),
        ));

        $this->addOptions(array(
            new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'civa'),
            new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
            new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'default'),
        ));

        $this->namespace = 'dr';
        $this->name = 'changeDate';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [maintenance:DRVT|INFO] task does things.
Call it with:

  [php symfony maintenance:DRVT|INFO]
EOF;
    }

    protected function execute($arguments = array(), $options = array())
    {

      // initialize the database connection
      $databaseManager = new sfDatabaseManager($this->configuration);
      $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
      
      $dr = DRClient::getInstance()->find($arguments['id']);

      $date = $arguments['date'];

      if(!$dr) {
        echo "ERREUR;".$dr->_id.";La DR n'existe pas\n";
        return;
      }

      if(!$dr->isValideeCiva()) {

        return;
      }

      if($dr->validee <= $date) {
        return;
      }

      $dr->validee = $date;
      
      echo "INFO;".$dr->_id.";Date de validation passé au ".$date."\n";

      $dr->save();
    }
    
}
<commit_msg>Tâche changement de date dans la DR<commit_after><?php

class DRChangeDateTask extends sfBaseTask
{

    protected function configure()
    {
        $this->addArguments(array(
          new sfCommandArgument('id', sfCommandArgument::REQUIRED, 'id'),
          new sfCommandArgument('date', sfCommandArgument::REQUIRED, 'date'),
        ));

        $this->addOptions(array(
            new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'civa'),
            new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
            new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'default'),
        ));

        $this->namespace = 'dr';
        $this->name = 'changeDate';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [maintenance:DRVT|INFO] task does things.
Call it with:

  [php symfony maintenance:DRVT|INFO]
EOF;
    }

    protected function execute($arguments = array(), $options = array())
    {

      // initialize the database connection
      $databaseManager = new sfDatabaseManager($this->configuration);
      $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
      
      $dr = DRClient::getInstance()->find($arguments['id']);

      $date = $arguments['date'];

      if(!$dr) {
        echo "ERREUR;".$dr->_id.";La DR n'existe pas\n";
        return;
      }

      if(!$dr->isValideeCiva()) {

        return;
      }

      if($dr->validee <= $date) {
        return;
      }

      $dr->validee = $date;
      $dr->modifiee = $date;

      echo "INFO;".$dr->_id.";Date de validation passé au ".$date."\n";

      $dr->save();
    }

}
{'fraction_non_alphanumeric': 0.1558219178082192, 'fraction_numerical': 0.0, 'mean_word_length': 2.8601321585903086, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 36, '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': '5928151', 'n_tokens_mistral': 1014, 'n_tokens_neox': 1010, 'n_words': 210}