<commit_before><?php

class maintenanceDRUpdateTask extends sfBaseTask
{
  protected function configure()
  {
    // // add your own arguments here
    // $this->addArguments(array(
    //   new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My argument'),
    // ));

    $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'),
      // add your own options here
      new sfCommandOption('campagne', null, sfCommandOption::PARAMETER_REQUIRED, 'Campagne', '2011'),
    ));

    $this->namespace        = 'maintenance';
    $this->name             = 'dr-update';
    $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_ids = sfCouchdbManager::getClient("DR")->getAllByCampagne($options['campagne'], sfCouchdbClient::HYDRATE_ON_DEMAND)->getIds();

    foreach ($dr_ids as $id) {
            $dr = sfCouchdbManager::getClient()->retrieveDocumentById($id);
            if ($dr->exist('modifiee')) {
                $this->logSection('try', $dr->get('_id'));
                $modifiee = $dr->get('modifiee');
                $dr->remove('modifiee');
                $dr->update();
                $dr->add('modifiee', $modifiee);
                if ($dr->isModified()) {
                    $this->logSection('updated', $dr->get('_id'));
                }
                
                $dr->save();
                
            }
            /*$dr = sfCouchdbManager::getClient()->retrieveDocumentById($id);
            
            foreach($dr->recolte->getAppellations() as $appellation) {
                foreach($appellation->getLieux() as $lieu) {
                    
                    foreach($lieu->acheteurs as $types) {
                        foreach($types as $acheteur) {
			    if(round($acheteur->dontdplc, 2) != $acheteur->dontdplc) {
		             $this->logSection("DR", $id);
		             $this->logSection("acheteur", $acheteur->dontdplc);
		             $this->logSection("dplc", $lieu->getDplc());
		            }
                            if ($acheteur->dontdplc == $lieu->getTotalDontDplcRecapitulatifVente()) {
                                if ($lieu->getTotalSuperficieRecapitulatifVente() == $lieu->getTotalSuperficie() && $acheteur->dontdplc != $lieu->getDplc()) {
                                    $this->logSection("DR", $id);
 				    $this->logSection("total", $lieu->getTotalDontDplcRecapitulatifVente());
                                    $this->logSection("acheteur", $acheteur->dontdplc);
                                    $acheteur->dontdplc = $lieu->getDplc();
                                    $this->logSection("new acheteur", $acheteur->dontdplc);
                                    $this->logSection("lieu", $lieu->getDplc());
                                    $this->log("--------------------------");
                                    
                                }
                            }
                        }
                    }
                }
            }*/
           
    }
    // add your code here
  }
}<commit_msg>Tache pour updater les DR<commit_after><?php

class maintenanceDRUpdateTask extends sfBaseTask {

    protected function configure() {
        // // add your own arguments here
        // $this->addArguments(array(
        //   new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED, 'My argument'),
        // ));

        $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'),
            // add your own options here
            new sfCommandOption('campagne', null, sfCommandOption::PARAMETER_REQUIRED, 'Campagne', '2011'),
        ));

        $this->namespace = 'maintenance';
        $this->name = 'dr-update';
        $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_ids = sfCouchdbManager::getClient("DR")->getAllByCampagne($options['campagne'], sfCouchdbClient::HYDRATE_ON_DEMAND)->getIds();

        foreach ($dr_ids as $id) {
            $dr = sfCouchdbManager::getClient()->retrieveDocumentById($id);
            $this->logSection('try', $dr->get('_id'));
            if ($dr->exist('modifiee')) {
                $modifiee = $dr->get('modifiee');
                $dr->remove('modifiee');
                $dr->update();
                $dr->add('modifiee', $modifiee);
                if ($dr->isModified()) {
                    $this->logSection('validaded updated', $dr->get('_id'));
                }

                $dr->save();
            } else {
                $dr->update();
                if ($dr->isModified()) {
                    $this->logSection('updated', $dr->get('_id'));
                }
                $dr->save();
            }
            /* $dr = sfCouchdbManager::getClient()->retrieveDocumentById($id);

              foreach($dr->recolte->getAppellations() as $appellation) {
              foreach($appellation->getLieux() as $lieu) {

              foreach($lieu->acheteurs as $types) {
              foreach($types as $acheteur) {
              if(round($acheteur->dontdplc, 2) != $acheteur->dontdplc) {
              $this->logSection("DR", $id);
              $this->logSection("acheteur", $acheteur->dontdplc);
              $this->logSection("dplc", $lieu->getDplc());
              }
              if ($acheteur->dontdplc == $lieu->getTotalDontDplcRecapitulatifVente()) {
              if ($lieu->getTotalSuperficieRecapitulatifVente() == $lieu->getTotalSuperficie() && $acheteur->dontdplc != $lieu->getDplc()) {
              $this->logSection("DR", $id);
              $this->logSection("total", $lieu->getTotalDontDplcRecapitulatifVente());
              $this->logSection("acheteur", $acheteur->dontdplc);
              $acheteur->dontdplc = $lieu->getDplc();
              $this->logSection("new acheteur", $acheteur->dontdplc);
              $this->logSection("lieu", $lieu->getDplc());
              $this->log("--------------------------");

              }
              }
              }
              }
              }
              } */
        }
        // add your code here
    }

}
{'fraction_non_alphanumeric': 0.1602736051502146, 'fraction_numerical': 0.0013412017167381974, 'mean_word_length': 1.965009940357853, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387498', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2127, 'n_words': 334}