<commit_before><?php

namespace HealthCareAbroad\HelperBundle\Command;

use HealthCareAbroad\InstitutionBundle\Entity\Institution;
use Doctrine\Tests\ORM\Proxy\SleepClass;
use Assetic\Exception\Exception;
use HealthCareAbroad\HelperBundle\Entity\CommandScriptLog;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

class ScriptCleanUpWebsitesCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('script:loadWebsites')->setDescription('Check scripts');
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getEntityManager();
        $results = $em->getRepository('InstitutionBundle:Institution')->findAll();
        
        $defaultValue = array();
        foreach($results as $institution) {
            echo "id:" .$institution->getId(). "\n";
            $oldData =  $institution->getWebsiteBackUp();
            $websitesArray = json_decode(\stripslashes($oldData), true);
            
            if (\is_array($websitesArray)) {
                if(isset($websitesArray['main'])) {
                    $institution->setWebsites(isset($websitesArray['main']) ? $websitesArray['main'] : '' );
                    if($institution->getSocialMediaSites() == ''){
                        $defaultValue['facebook'] = isset($websitesArray['facebook']) ? $websitesArray['facebook'] : '';
                        $defaultValue['twitter'] = isset($websitesArray['twitter']) ? $websitesArray['twitter'] : '';
                        $defaultValue['googleplus'] = '';
                        $institution->setSocialMediaSites(\json_encode($defaultValue));
                        
                        echo "SocialMediaSites" .$institution->getSocialMediaSites()."\n";
                    }
                    echo "new:" .$institution->getWebsites(). "\n";
                }
            }
            $em->persist($institution);
        }
        $em->flush();
        
        echo "done\n";
        exit;
    }
    
}<commit_msg>moved persist statement inside if block<commit_after><?php

namespace HealthCareAbroad\HelperBundle\Command;

use HealthCareAbroad\InstitutionBundle\Entity\Institution;
use Doctrine\Tests\ORM\Proxy\SleepClass;
use Assetic\Exception\Exception;
use HealthCareAbroad\HelperBundle\Entity\CommandScriptLog;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

class ScriptCleanUpWebsitesCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('script:loadWebsites')->setDescription('Check scripts');
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getEntityManager();
        $results = $em->getRepository('InstitutionBundle:Institution')->findAll();
        
        $defaultValue = array();
        foreach($results as $institution) {
            echo "id:" .$institution->getId(). "\n";
            $oldData =  $institution->getWebsiteBackUp();
            $websitesArray = json_decode(\stripslashes($oldData), true);
            
            if (\is_array($websitesArray)) {
                if(isset($websitesArray['main'])) {
                    $institution->setWebsites(isset($websitesArray['main']) ? $websitesArray['main'] : '' );
                    if($institution->getSocialMediaSites() == ''){
                        $defaultValue['facebook'] = isset($websitesArray['facebook']) ? $websitesArray['facebook'] : '';
                        $defaultValue['twitter'] = isset($websitesArray['twitter']) ? $websitesArray['twitter'] : '';
                        $defaultValue['googleplus'] = '';
                        $institution->setSocialMediaSites(\json_encode($defaultValue));
                        
                        echo "SocialMediaSites" .$institution->getSocialMediaSites()."\n";
                    }
                    
                    $em->persist($institution);
                    echo "new:" .$institution->getWebsites(). "\n";
                }
            }
            
        }
        $em->flush();
        
        echo "done\n";
        exit;
    }
    
}
{'fraction_non_alphanumeric': 0.13564398801882754, 'fraction_numerical': 0.0, 'mean_word_length': 2.4681008902077153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '6021903', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1199, 'n_words': 165}