<commit_before><?php

namespace Ach\PoManagerBundle\Command;

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

class SendNotificationCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('SendNotification')
	    ->addArgument('host')
	    ->addArgument('baseUrl')
            ->setDescription('Send notification email for event in the database')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $context = $this->getContainer()->get('router')->getContext();
        $context->setHost($input->getArgument('host'));
        $context->setScheme('http');
        $context->setBaseUrl($input->getArgument('baseUrl'));
		
		$repositoryNotification = $this->getContainer()->get('doctrine')
		    ->getManager()
		    ->getRepository('AchPoManagerBundle:Notification');
		
		$listNotifications = $repositoryNotification->findAll();
		
		$em = $this->getContainer()->get('doctrine')->getManager();

        // get root dir of app on the server for email attachment retrieval on the disk
        $files_root_path = $this->getContainer()->get('kernel')->getRootdir() . '/../..';
        
		$log = null;
		
		// scan all the pending notification of the table and send message for each
		foreach($listNotifications as $notification)
		{
			$log = $this->getContainer()->get('ach_po_manager.send_notification')->sendNotification($notification, $files_root_path);
			$output->writeln($log);
			$em->remove($notification);
		}
		
		/* $transport = $this->getContainer()->get('mailer')->getTransport(); */
		/* if (!$transport instanceof \Swift_Transport_SpoolTransport) { */
		/* 	return; */
		/* } */
		
		/* $spool = $transport->getSpool(); */
		/* 	if (!$spool instanceof \Swift_MemorySpool) { */
		/* 	return; */
		/* } */
		
		/* $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));	 */
		
		$em->flush();
		
		//$output->writeln('SendNotification executed: ' . $log);
    }
}<commit_msg>move the flush statement to avoid notification to be sent multiple time if next notification does not go through<commit_after><?php

namespace Ach\PoManagerBundle\Command;

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

class SendNotificationCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('SendNotification')
	    ->addArgument('host')
	    ->addArgument('baseUrl')
            ->setDescription('Send notification email for event in the database')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $context = $this->getContainer()->get('router')->getContext();
        $context->setHost($input->getArgument('host'));
        $context->setScheme('http');
        $context->setBaseUrl($input->getArgument('baseUrl'));
		
		$repositoryNotification = $this->getContainer()->get('doctrine')
		    ->getManager()
		    ->getRepository('AchPoManagerBundle:Notification');
		
		$listNotifications = $repositoryNotification->findAll();
		
		$em = $this->getContainer()->get('doctrine')->getManager();

        // get root dir of app on the server for email attachment retrieval on the disk
        $files_root_path = $this->getContainer()->get('kernel')->getRootdir() . '/../..';
        
		$log = null;
		
		// scan all the pending notification of the table and send message for each
		foreach($listNotifications as $notification)
		{
			$log = $this->getContainer()->get('ach_po_manager.send_notification')->sendNotification($notification, $files_root_path);
			$output->writeln($log);
			$em->remove($notification);
            $em->flush();
		}
		
		/* $transport = $this->getContainer()->get('mailer')->getTransport(); */
		/* if (!$transport instanceof \Swift_Transport_SpoolTransport) { */
		/* 	return; */
		/* } */
		
		/* $spool = $transport->getSpool(); */
		/* 	if (!$spool instanceof \Swift_MemorySpool) { */
		/* 	return; */
		/* } */
		
		/* $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));	 */
		
		
		//$output->writeln('SendNotification executed: ' . $log);
    }
}
{'fraction_non_alphanumeric': 0.1548196582999367, 'fraction_numerical': 0.0, 'mean_word_length': 3.252914798206278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, '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': '7247620', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1281, 'n_words': 238}