<commit_before><?php

namespace EVT\IntranetBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class ImportPublishedShowroomsCommand
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 Bodaclick
 */
class ImportPublishedShowroomsCommand extends ContainerAwareCommand
{
    /**
     * @see Command
     */
    protected function configure()
    {
        $this
            ->setName('evt:showroom:import')
            ->setDescription('Import published showroom CSV')
            ->setDefinition(
                [
                    new InputArgument('file', InputArgument::REQUIRED, 'CSV file with fields name, url'),
                    new InputArgument('username', InputArgument::REQUIRED, 'The username of an employee'),
                    new InputArgument('urlback', InputArgument::REQUIRED, 'Url called after the mail is sent'),
                ]
            )
            ->setHelp(
                <<<EOT
    The <info>evt:showroom:import</info> Import published showroom CSV:

  <info>php app/console evt:showroom:import importedCSV.csv employee www.vertical.com/hotel-california</info>
EOT
            );
    }

    /**
     * @see Command
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $adminUsername = $input->getArgument('username');
        $urlBack = $input->getArgument('urlback');

        $command = $this->getApplication()->find('evt:showroom:publish');

        $fh = fopen($input->getArgument('file'), 'r');
        while ($line = fgetcsv($fh)) {
            $arguments = array(
                'command' => 'evt:showroom:publish',
                'username'    => $adminUsername,
                'name' => $line[0],
                'url' => $line[1],
                'urlback' => $urlBack
            );

            $input = new ArrayInput($arguments);
            $command->run($input, $output);
        }
    }
}<commit_msg>[] - Do not import twice<commit_after><?php

namespace EVT\IntranetBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class ImportPublishedShowroomsCommand
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 Bodaclick
 */
class ImportPublishedShowroomsCommand extends ContainerAwareCommand
{
    /**
     * @see Command
     */
    protected function configure()
    {
        $this
            ->setName('evt:showroom:import')
            ->setDescription('Import published showroom CSV')
            ->setDefinition(
                [
                    new InputArgument('file', InputArgument::REQUIRED, 'CSV file with fields name, url'),
                    new InputArgument('username', InputArgument::REQUIRED, 'The username of an employee'),
                    new InputArgument('urlback', InputArgument::REQUIRED, 'Url called after the mail is sent'),
                ]
            )
            ->setHelp(
                <<<EOT
    The <info>evt:showroom:import</info> Import published showroom CSV:

  <info>php app/console evt:showroom:import importedCSV.csv employee www.vertical.com/hotel-california</info>
EOT
            );
    }

    /**
     * @see Command
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $adminUsername = $input->getArgument('username');
        $urlBack = $input->getArgument('urlback');

        $command = $this->getApplication()->find('evt:showroom:publish');

        $fh = fopen($input->getArgument('file'), 'r');
        while ($line = fgetcsv($fh)) {

            $val = $this->getContainer()->get('snc_redis.default_client')
                ->get('evt_showrooms:'. str_replace(['http://', 'https://', 'www.'], [''], $line[1]));

            if (null === $val) {
                $arguments = array(
                    'command' => 'evt:showroom:publish',
                    'username'    => $adminUsername,
                    'name' => $line[0],
                    'url' => $line[1],
                    'urlback' => $urlBack
                );

                $input = new ArrayInput($arguments);
                $command->run($input, $output);

                $this->getContainer()->get('snc_redis.default_client')
                    ->set('evt_showrooms:'. str_replace(['http://', 'https://', 'www.'], [''], $line[1]), '1');
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1387376487194999, 'fraction_numerical': 0.0030248033877797943, 'mean_word_length': 2.3536173089925625, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 53, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '1890403', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1337, 'n_words': 261}