<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ImportEtablissement
 *
 * @author mathurin
 */

namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use AppBundle\Manager\PassageManager;
use Symfony\Component\Console\Helper\ProgressBar;
use AppBundle\Manager\ContratManager;

class PassageEnAttenteCommand extends ContainerAwareCommand {

    protected $dm;

    protected function configure() {
        $this
                ->setName('maintenance:passage-en-attente')
                ->setDescription('Passage en attente');
    }

    protected function execute(InputInterface $input, OutputInterface $output) {

        $this->dm = $this->getContainer()->get('doctrine_mongodb.odm.default_document_manager');

        $q = $this->dm->createQueryBuilder('AppBundle:Passage')->getQuery();

        $iterableResult = $q->iterate();

        foreach ($iterableResult as $passage) {
            if($passage->getStatut() != PassageManager::STATUT_EN_ATTENTE) {
                continue;
            }

            if(!$passage->getContrat()->isAVenir() && !$passage->getContrat()->isEnCours()) {
                continue;
            }

            if(!$passage->isSousContrat()) {
                continue;
            }

            if($passage->getDatePrevision()->format('Y') < 2015) {
                continue;
            }

            $previousPassage = $this->getContainer()->get('passage.manager')->passagePrecedentSousContrat($passage);

            if($previousPassage && !$previousPassage->isRealise() && !$previousPassage->isPlanifie()) {
                continue;
            }

            $passage->setDateDebut($passage->getDatePrevision());
            $passage->setStatut(PassageManager::STATUT_A_PLANIFIER);

            echo "Passage de ".$passage->getDatePrevision()->format('M Y')." pour l'établissment ".$passage->getEtablissementInfos()->getNom()." dans le contrat n°".$passage->getContrat()->getNumeroArchive()." : ".$passage->getContrat()->getId()." ".$passage->getId()."\n";
        }

        //$this->dm->flush();
    }
}<commit_msg>Correction ok de la tache de mise à jour des passages en attente<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ImportEtablissement
 *
 * @author mathurin
 */

namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use AppBundle\Manager\PassageManager;
use Symfony\Component\Console\Helper\ProgressBar;
use AppBundle\Manager\ContratManager;

class PassageEnAttenteCommand extends ContainerAwareCommand {

    protected $dm;

    protected function configure() {
        $this
                ->setName('maintenance:passage-en-attente')
                ->setDescription('Passage en attente');
    }

    protected function execute(InputInterface $input, OutputInterface $output) {

        $this->dm = $this->getContainer()->get('doctrine_mongodb.odm.default_document_manager');

        $q = $this->dm->createQueryBuilder('AppBundle:Passage')->getQuery();

        $iterableResult = $q->iterate();

        foreach ($iterableResult as $passage) {
            if($passage->getStatut() != PassageManager::STATUT_EN_ATTENTE) {
                continue;
            }

            if(!$passage->getContrat()->isAVenir() && !$passage->getContrat()->isEnCours()) {
                continue;
            }

            if(!$passage->isSousContrat()) {
                continue;
            }

            if($passage->getDatePrevision()->format('Y') < 2015) {
                continue;
            }

            $previousPassage = $this->getContainer()->get('passage.manager')->passagePrecedentSousContrat($passage);

            if($previousPassage && !$previousPassage->isRealise() && !$previousPassage->isPlanifie()) {
                continue;
            }

            $passage->setDateDebut($passage->getDatePrevision());
            $passage->setStatut(PassageManager::STATUT_A_PLANIFIER);

            echo "Passage de ".$passage->getDatePrevision()->format('M Y')." pour l'établissment ".$passage->getEtablissementInfos()->getNom()." dans le contrat n°".$passage->getContrat()->getNumeroArchive()." : ".$passage->getContrat()->getId()." ".$passage->getId()."\n";
        }

        $this->dm->flush();
    }
}
{'fraction_non_alphanumeric': 0.1414387031408308, 'fraction_numerical': 0.0016210739614994933, 'mean_word_length': 2.9519615692554044, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 75, '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': '5104573', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1386, 'n_words': 236}