<commit_before><?php

class DRUpdateWithConfigurationTask extends sfBaseTask
{

    protected function configure()
    {
        // // add your own arguments here
        $this->addArguments(array(
        ));

        $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 = 'update_with_configuration';
        $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();

        $drs = sfCouchdbManager::getClient("DR")->getAll(sfCouchdbClient::HYDRATE_JSON);
        //$drs = array(sfCouchdbManager::getClient("DR")->retrieveDocumentById('DR-1623700100-2010', sfCouchdbClient::HYDRATE_JSON));
		foreach ($drs as $dr){
            $dr_clone = clone $dr;
            if (isset($dr->recolte->certification)) {

                continue;
            }

            if (count($dr->recolte) == 0) {
                
                continue;
            }

            $dr_clone->acheteurs = new stdClass();
            $dr_clone->acheteurs->certification = new stdClass();
            $dr_clone->acheteurs->certification->genre = new stdClass();
            foreach($dr->acheteurs as $acheteur_appellation_key => $acheteur_appellation) {
                $dr_clone->acheteurs->certification->genre->{$acheteur_appellation_key} = clone $acheteur_appellation;
            }

            $dr_clone->recolte = new stdClass();
            $dr_clone->recolte->certification = new stdClass();
			$dr_clone->recolte->certification->genre = new stdClass();
            
            $dr_clone->recolte->certification->total_volume = null;
            $dr_clone->recolte->certification->total_superficie = null;
            $dr_clone->recolte->certification->volume_revendique = null;
            $dr_clone->recolte->certification->dplc = null;
            $dr_clone->recolte->certification->usages_industriels_calcule = null;

            $dr_clone->recolte->certification->genre->total_volume = null;
            $dr_clone->recolte->certification->genre->total_superficie = null;
            $dr_clone->recolte->certification->genre->volume_revendique = null;
            $dr_clone->recolte->certification->genre->dplc = null;
            $dr_clone->recolte->certification->genre->usages_industriels_calcule = null;

			foreach ($dr->recolte as $key_app => $appellation){	
				if(preg_match("/^appellation_/", $key_app) && $appellation instanceof stdClass){
					$dr_clone->recolte->certification->genre->{$key_app} = clone $appellation;
                    unset($dr_clone->recolte->certification->genre->{$key_app}->lieu);
                    $dr_clone->recolte->certification->genre->{$key_app}->usages_industriels_calcule = null;

                    if(isset($appellation->dplc)) {
                        $dr_clone->recolte->certification->genre->{$key_app}->usages_industriels_calcule = $appellation->dplc;<commit_msg>Correction d'un bug avec lieu<commit_after><?php

class DRUpdateWithConfigurationTask extends sfBaseTask
{

    protected function configure()
    {
        // // add your own arguments here
        $this->addArguments(array(
        ));

        $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 = 'update_with_configuration';
        $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();

        $drs = sfCouchdbManager::getClient("DR")->getAll(sfCouchdbClient::HYDRATE_JSON);
        //$drs = array(sfCouchdbManager::getClient("DR")->retrieveDocumentById('DR-7523700100-2011', sfCouchdbClient::HYDRATE_JSON));
		
        foreach ($drs as $dr){
            $dr_clone = clone $dr;
            if (isset($dr->recolte->certification)) {

                continue;
            }

            if (count($dr->recolte) == 0) {
                
                continue;
            }

            $dr_clone->acheteurs = new stdClass();
            $dr_clone->acheteurs->certification = new stdClass();
            $dr_clone->acheteurs->certification->genre = new stdClass();
            foreach($dr->acheteurs as $acheteur_appellation_key => $acheteur_appellation) {
                $dr_clone->acheteurs->certification->genre->{$acheteur_appellation_key} = clone $acheteur_appellation;
            }

            $dr_clone->recolte = new stdClass();
            $dr_clone->recolte->certification = new stdClass();
			$dr_clone->recolte->certification->genre = new stdClass();
            
            $dr_clone->recolte->certification->total_volume = null;
            $dr_clone->recolte->certification->total_superficie = null;
            $dr_clone->recolte->certification->volume_revendique = null;
            $dr_clone->recolte->certification->dplc = null;
            $dr_clone->recolte->certification->usages_industriels_calcule = null;

            $dr_clone->recolte->certification->genre->total_volume = null;
            $dr_clone->recolte->certification->genre->total_superficie = null;
            $dr_clone->recolte->certification->genre->volume_revendique = null;
            $dr_clone->recolte->certification->genre->dplc = null;
            $dr_clone->recolte->certification->genre->usages_industriels_calcule = null;

			foreach ($dr->recolte as $key_app => $appellation){	
				if(preg_match("/^appellation_/", $key_app) && $appellation instanceof stdClass){
					$dr_clone->recolte->certification->genre->{$key_app} = clone $appellation;

                    foreach($dr_clone->recolte->certification->genre->{$key_app} as $key_lieu => $lieu) {
                        if(preg_match("/^lieu/", $key_lieu) && $lieu instanceof stdClass){
                            unset($dr_clone->recolte->certification->genre->{$key_app}->{$key_lieu});
                        }
                    }
                    
                    $dr_clone->recolte->certification->genre->{$key_app}->usages_industriels_calcule = null;

                    if(isset($appellation->dplc)) {
                        $dr_clone->recolte->certification->genre->{$key_app}->usages_industriels_calcule = $appellation->dplc;
{'fraction_non_alphanumeric': 0.13901760889712697, 'fraction_numerical': 0.003971931682775056, 'mean_word_length': 2.7322134387351777, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 188, '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': '12835', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2218, 'n_words': 322}